home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / ooo2wordml_draw.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  108KB  |  1,878 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: ooo2wordml_draw.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:05:56 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xalan="http://xml.apache.org/xalan" xmlns:oleextracter="MyOleExtracter" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw xalan oleextracter" extension-element-prefixes="oleextracter">
  37.     <xsl:include href="ooo2wordml_custom_draw.xsl"/>
  38.     <xsl:key name="stroke-dash-style" match="draw:stroke-dash" use="@draw:name"/>
  39.     <xsl:key name="fill-image" match="draw:fill-image" use="@draw:name"/>
  40.     <xsl:key name="draw-gradient" match="draw:gradient " use="@draw:name"/>
  41.     <xsl:template name="PageLevelGraphic">
  42.         <xsl:for-each select="//draw:*[@text:anchor-type='page']">
  43.             <xsl:apply-templates select="."/>
  44.         </xsl:for-each>
  45.     </xsl:template>
  46.     <xsl:template match="draw:*">
  47.         <xsl:param name="TargetMeasure" select="'pt'"/>
  48.         <xsl:param name="x-adjust" select="0"/>
  49.         <xsl:param name="y-adjust" select="0"/>
  50.         <xsl:param name="force-draw" select="'false'"/>
  51.         <xsl:variable name="MeasureMark">
  52.             <xsl:choose>
  53.                 <xsl:when test="$TargetMeasure = 'twip'"/>
  54.                 <xsl:otherwise>
  55.                     <xsl:value-of select="$TargetMeasure"/>
  56.                 </xsl:otherwise>
  57.             </xsl:choose>
  58.         </xsl:variable>
  59.         <xsl:choose>
  60.             <!--
  61.                           deal with captions and frames first. draw:text-box is a powerfull element in OOo, its GUI name is frame. And OOo use it to contain Captions
  62.                           Since there is not a corresponding object in word, so we draw the text-box itself and its children separately. If it look like a Caption only frame
  63.                           we'll adjust the text-box position to make it look pretty
  64.              -->
  65.             <!-- skip all not force draw children , must be first case -->
  66.             <xsl:when test="ancestor::draw:text-box and $force-draw='false' "/>
  67.             <xsl:when test="name() = 'draw:text-box'">
  68.                 <!-- draw the text-box itself -->
  69.                 <w:r>
  70.                     <w:pict>
  71.                         <xsl:variable name="text-y-adjust">
  72.                             <xsl:choose>
  73.                                 <xsl:when test="count(text:p/draw:*) = 1 and (string-length(text:p/draw:*[position()=1]/@svg:x) =0 or number(concat('0',translate(text:p/draw:*[position()=1]/@svg:x,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','') ))=0) and  (string-length(text:p/draw:*[position()=1]/@svg:y)=0 or  number(concat('0',translate(text:p/draw:*[position()=1]/@svg:x,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','') ))=0 ) ">
  74.                                     <xsl:variable name="pic-height">
  75.                                         <xsl:choose>
  76.                                             <xsl:when test="name(text:p/draw:*[position()=1]) = 'draw:g' or name(text:p/draw:*[position()=1]) = 'draw:a'">
  77.                                                 <xsl:variable name="BigestWindow">
  78.                                                     <xsl:call-template name="GetWindowSize">
  79.                                                         <xsl:with-param name="nodeSet" select="text:p/draw:*[position()=1]/draw:*"/>
  80.                                                         <xsl:with-param name="x-adjust" select="$x-adjust"/>
  81.                                                         <xsl:with-param name="y-adjust" select="$y-adjust"/>
  82.                                                     </xsl:call-template>
  83.                                                 </xsl:variable>
  84.                                                 <xsl:value-of select="substring-after($BigestWindow,'y2:')  - substring-after(substring-before($BigestWindow,';x2'), 'y1:') + number(concat('0',translate($y-adjust,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','')))"/>
  85.                                             </xsl:when>
  86.                                             <xsl:when test="text:p/draw:*[position()=1]/@svg:height">
  87.                                                 <xsl:call-template name="Add-With-Measure">
  88.                                                     <xsl:with-param name="value1" select="text:p/draw:*[position()=1]/@svg:height"/>
  89.                                                     <xsl:with-param name="value2" select="$y-adjust"/>
  90.                                                 </xsl:call-template>
  91.                                             </xsl:when>
  92.                                             <xsl:when test="text:p/draw:*[position()=1]/@fo:min-height">
  93.                                                 <xsl:call-template name="Add-With-Measure">
  94.                                                     <xsl:with-param name="value1" select="text:p/draw:*[position()=1]/@fo:min-height"/>
  95.                                                     <xsl:with-param name="value2" select="$y-adjust"/>
  96.                                                 </xsl:call-template>
  97.                                             </xsl:when>
  98.                                             <xsl:when test="ancestor::draw:frame">
  99.                                                 <xsl:call-template name="Add-With-Measure">
  100.                                                     <xsl:with-param name="value1" select="ancestor::draw:frame/@svg:height"/>
  101.                                                     <xsl:with-param name="value2" select="$y-adjust"/>
  102.                                                 </xsl:call-template>
  103.                                             </xsl:when>
  104.                                         </xsl:choose>
  105.                                     </xsl:variable>
  106.                                     <xsl:variable name="min-height">
  107.                                         <xsl:call-template name="ConvertMeasure">
  108.                                             <xsl:with-param name="TargetMeasure" select="'in'"/>
  109.                                             <xsl:with-param name="value" select="@fo:min-height"/>
  110.                                         </xsl:call-template>
  111.                                     </xsl:variable>
  112.                                     <xsl:choose>
  113.                                         <xsl:when test="$min-height - $pic-height < 0.001">
  114.                                             <!-- If control goes here, it much like that this text-box is used for containt graphic caption only -->
  115.                                             <xsl:value-of select="$pic-height - 0.1"/>
  116.                                         </xsl:when>
  117.                                         <xsl:otherwise>
  118.                                             <xsl:value-of select="$y-adjust"/>
  119.                                         </xsl:otherwise>
  120.                                     </xsl:choose>
  121.                                 </xsl:when>
  122.                                 <xsl:otherwise>
  123.                                     <xsl:value-of select="$y-adjust"/>
  124.                                 </xsl:otherwise>
  125.                             </xsl:choose>
  126.                         </xsl:variable>
  127.                         <xsl:variable name="shape-type">
  128.                             <xsl:choose>
  129.                                 <xsl:when test="$text-y-adjust = $y-adjust">
  130.                                     <xsl:value-of select="'#_x0000_t202'"/>
  131.                                 </xsl:when>
  132.                             </xsl:choose>
  133.                         </xsl:variable>
  134.                         <xsl:call-template name="DrawElements">
  135.                             <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  136.                             <xsl:with-param name="x-adjust" select="$x-adjust"/>
  137.                             <xsl:with-param name="y-adjust" select="$text-y-adjust"/>
  138.                             <xsl:with-param name="force-draw" select="'true'"/>
  139.                             <xsl:with-param name="shape-type" select="$shape-type"/>
  140.                         </xsl:call-template>
  141.                     </w:pict>
  142.                 </w:r>
  143.                 <!-- draw the real object first -->
  144.                 <xsl:if test="./text:p/draw:*">
  145.                     <xsl:apply-templates select="./text:p/draw:*">
  146.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  147.                         <xsl:with-param name="x-adjust">
  148.                             <xsl:call-template name="Add-With-Measure">
  149.                                 <xsl:with-param name="value1" select="@svg:x"/>
  150.                                 <xsl:with-param name="value2" select="$x-adjust"/>
  151.                             </xsl:call-template>
  152.                         </xsl:with-param>
  153.                         <xsl:with-param name="y-adjust">
  154.                             <xsl:call-template name="Add-With-Measure">
  155.                                 <xsl:with-param name="value1" select="@svg:y"/>
  156.                                 <xsl:with-param name="value2" select="$y-adjust"/>
  157.                             </xsl:call-template>
  158.                         </xsl:with-param>
  159.                         <xsl:with-param name="force-draw" select="'true'"/>
  160.                     </xsl:apply-templates>
  161.                 </xsl:if>
  162.             </xsl:when>
  163.             <!-- end deal with captions and frames -->
  164.             <xsl:when test=" name() = 'draw:frame' ">
  165.                 <xsl:variable name="BigestWindow">
  166.                     <xsl:call-template name="GetWindowSize">
  167.                         <xsl:with-param name="nodeSet" select="."/>
  168.                         <xsl:with-param name="x-adjust" select="$x-adjust"/>
  169.                         <xsl:with-param name="y-adjust" select="$y-adjust"/>
  170.                     </xsl:call-template>
  171.                 </xsl:variable>
  172.                 <xsl:apply-templates select="draw:* ">
  173.                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  174.                     <xsl:with-param name="x-adjust" select="concat(substring-after(substring-before($BigestWindow,';y1'), 'x1:'), 'in')"/>
  175.                     <xsl:with-param name="y-adjust" select="concat(substring-after(substring-before($BigestWindow,';x2'), 'y1:') , 'in')"/>
  176.                     <xsl:with-param name="force-draw" select="$force-draw"/>
  177.                 </xsl:apply-templates>
  178.             </xsl:when>
  179.             <xsl:when test="name() = 'draw:g'">
  180.                 <w:r>
  181.                     <w:pict>
  182.                         <xsl:element name="v:group">
  183.                             <xsl:variable name="BigestWindow">
  184.                                 <xsl:choose>
  185.                                     <xsl:when test="name() = 'draw:g'">
  186.                                         <xsl:call-template name="GetWindowSize">
  187.                                             <xsl:with-param name="nodeSet" select="draw:*"/>
  188.                                             <xsl:with-param name="x-adjust" select="$x-adjust"/>
  189.                                             <xsl:with-param name="y-adjust" select="$y-adjust"/>
  190.                                         </xsl:call-template>
  191.                                     </xsl:when>
  192.                                     <xsl:when test="name() = 'draw:frame'">
  193.                                         <xsl:call-template name="GetWindowSize">
  194.                                             <xsl:with-param name="nodeSet" select="."/>
  195.                                             <xsl:with-param name="x-adjust" select="$x-adjust"/>
  196.                                             <xsl:with-param name="y-adjust" select="$y-adjust"/>
  197.                                         </xsl:call-template>
  198.                                     </xsl:when>
  199.                                 </xsl:choose>
  200.                             </xsl:variable>
  201.                             <xsl:variable name="x">
  202.                                 <xsl:call-template name="ConvertMeasure">
  203.                                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  204.                                     <xsl:with-param name="value" select="concat(substring-after(substring-before($BigestWindow,';y1'), 'x1:'), 'in')"/>
  205.                                 </xsl:call-template>
  206.                             </xsl:variable>
  207.                             <xsl:variable name="y">
  208.                                 <xsl:call-template name="ConvertMeasure">
  209.                                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  210.                                     <xsl:with-param name="value" select="concat(substring-after(substring-before($BigestWindow,';x2'), 'y1:') , 'in')"/>
  211.                                 </xsl:call-template>
  212.                             </xsl:variable>
  213.                             <xsl:variable name="width">
  214.                                 <xsl:call-template name="ConvertMeasure">
  215.                                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  216.                                     <xsl:with-param name="value" select="concat(substring-after(substring-before($BigestWindow,';y2'), 'x2:')  -  substring-after(substring-before($BigestWindow,';y1'), 'x1:') , 'in')"/>
  217.                                 </xsl:call-template>
  218.                             </xsl:variable>
  219.                             <xsl:variable name="height">
  220.                                 <xsl:call-template name="ConvertMeasure">
  221.                                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  222.                                     <xsl:with-param name="value" select="concat(substring-after($BigestWindow,'y2:')  - substring-after(substring-before($BigestWindow,';x2'), 'y1:'), 'in')"/>
  223.                                 </xsl:call-template>
  224.                             </xsl:variable>
  225.                             <xsl:attribute name="id">
  226.                                 <xsl:value-of select="generate-id()"/>
  227.                             </xsl:attribute>
  228.                             <xsl:variable name="absolute">
  229.                                 <xsl:choose>
  230.                                     <xsl:when test="ancestor::draw:a"/>
  231.                                     <xsl:when test="@text:anchor-type = 'as-char' or @text:anchor-type = 'to-char'"/>
  232.                                     <xsl:otherwise>position:absolute</xsl:otherwise>
  233.                                 </xsl:choose>
  234.                             </xsl:variable>
  235.                             <xsl:if test="$TargetMeasure= 'pt'">
  236.                                 <xsl:attribute name="style">
  237.                                     <xsl:if test="string-length($absolute) > 0">
  238.                                         <xsl:value-of select="concat($absolute, ';')"/>
  239.                                     </xsl:if>
  240.                                     <xsl:value-of select="concat('margin-left:',$x ,$MeasureMark,';margin-top:', $y,$MeasureMark ,';width:', $width ,$MeasureMark , ';height:', $height,$MeasureMark)"/>
  241.                                 </xsl:attribute>
  242.                                 <xsl:attribute name="coordorigin">
  243.                                     <xsl:choose>
  244.                                         <!-- if we are in a text-box then oo will use comparative positions on us-->
  245.                                         <xsl:when test="name() = 'draw:frame' ">
  246.                                             <xsl:value-of select=" '0 0' "/>
  247.                                         </xsl:when>
  248.                                         <xsl:otherwise>
  249.                                             <xsl:value-of select="concat(round($x * 20), ',' , round($y * 20))"/>
  250.                                         </xsl:otherwise>
  251.                                     </xsl:choose>
  252.                                 </xsl:attribute>
  253.                                 <xsl:attribute name="coordsize">
  254.                                     <xsl:value-of select="concat(round($width * 20),',', round($height * 20) )"/>
  255.                                 </xsl:attribute>
  256.                             </xsl:if>
  257.                             <xsl:if test="$TargetMeasure= 'twip' ">
  258.                                 <xsl:attribute name="style">
  259.                                     <xsl:if test="string-length($absolute) > 0">
  260.                                         <xsl:value-of select="concat($absolute, ';')"/>
  261.                                     </xsl:if>
  262.                                     <xsl:value-of select="concat('left:',$x ,$MeasureMark,';top:', $y,$MeasureMark ,';width:', $width ,$MeasureMark , ';height:', $height,$MeasureMark)"/>
  263.                                 </xsl:attribute>
  264.                                 <xsl:attribute name="coordorigin">
  265.                                     <xsl:choose>
  266.                                         <!-- if we are in a text-box then oo will use comparative positions on us-->
  267.                                         <xsl:when test="name() = 'draw:frame' ">
  268.                                             <xsl:value-of select=" '0 0' "/>
  269.                                         </xsl:when>
  270.                                         <xsl:otherwise>
  271.                                             <xsl:value-of select="concat($x , ',' , $y)"/>
  272.                                         </xsl:otherwise>
  273.                                     </xsl:choose>
  274.                                 </xsl:attribute>
  275.                                 <xsl:attribute name="coordsize">
  276.                                     <xsl:value-of select="concat($width,',', $height )"/>
  277.                                 </xsl:attribute>
  278.                             </xsl:if>
  279.                             <xsl:choose>
  280.                                 <!-- if we are in a text-box then oo will use comparative positions on us-->
  281.                                 <xsl:when test="ancestor::draw:text-box">
  282.                                     <xsl:apply-templates select="draw:*">
  283.                                         <xsl:with-param name="TargetMeasure" select="'twip'"/>
  284.                                         <xsl:with-param name="x-adjust" select="concat(substring-after(substring-before($BigestWindow,';y1'), 'x1:'), 'in')"/>
  285.                                         <xsl:with-param name="y-adjust" select="concat(substring-after(substring-before($BigestWindow,';x2'), 'y1:') , 'in')"/>
  286.                                         <xsl:with-param name="force-draw" select="$force-draw"/>
  287.                                     </xsl:apply-templates>
  288.                                 </xsl:when>
  289.                                 <xsl:otherwise>
  290.                                     <xsl:apply-templates select="draw:*">
  291.                                         <xsl:with-param name="TargetMeasure" select="'twip'"/>
  292.                                         <xsl:with-param name="force-draw" select="$force-draw"/>
  293.                                     </xsl:apply-templates>
  294.                                 </xsl:otherwise>
  295.                             </xsl:choose>
  296.                         </xsl:element>
  297.                     </w:pict>
  298.                 </w:r>
  299.             </xsl:when>
  300.             <xsl:otherwise>
  301.                 <xsl:choose>
  302.                     <xsl:when test="name() = 'draw:a'">
  303.                         <xsl:call-template name="export_hyoerlink">
  304.                             <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  305.                             <xsl:with-param name="x-adjust" select="$x-adjust"/>
  306.                             <xsl:with-param name="y-adjust" select="$y-adjust"/>
  307.                             <xsl:with-param name="force-draw" select="$force-draw"/>
  308.                         </xsl:call-template>
  309.                     </xsl:when>
  310.                     <xsl:otherwise>
  311.                         <w:r>
  312.                             <w:pict>
  313.                                 <xsl:call-template name="DrawElements">
  314.                                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  315.                                     <xsl:with-param name="x-adjust" select="$x-adjust"/>
  316.                                     <xsl:with-param name="y-adjust" select="$y-adjust"/>
  317.                                     <xsl:with-param name="force-draw" select="$force-draw"/>
  318.                                 </xsl:call-template>
  319.                             </w:pict>
  320.                         </w:r>
  321.                     </xsl:otherwise>
  322.                 </xsl:choose>
  323.             </xsl:otherwise>
  324.         </xsl:choose>
  325.     </xsl:template>
  326.     <xsl:template name="GetWindowSize">
  327.         <xsl:param name="CurrPos" select="1"/>
  328.         <xsl:param name="nodeSet"/>
  329.         <xsl:param name="x-adjust" select="0"/>
  330.         <xsl:param name="y-adjust" select="0"/>
  331.         <xsl:variable name="CurrNodeWindow">
  332.             <xsl:call-template name="GetNodeWindow">
  333.                 <xsl:with-param name="CurrNode" select=" $nodeSet[ $CurrPos ]"/>
  334.                 <xsl:with-param name="x-adjust" select="$x-adjust"/>
  335.                 <xsl:with-param name="y-adjust" select="$y-adjust"/>
  336.             </xsl:call-template>
  337.         </xsl:variable>
  338.         <xsl:choose>
  339.             <!-- if we got to the last node, return it directly, or return the max window of current one and follwing ones -->
  340.             <xsl:when test="$CurrPos = count($nodeSet)">
  341.                 <xsl:value-of select="$CurrNodeWindow"/>
  342.             </xsl:when>
  343.             <xsl:otherwise>
  344.                 <xsl:variable name="CurrentWindow">
  345.                     <xsl:variable name="FollowingWindow">
  346.                         <xsl:call-template name="GetWindowSize">
  347.                             <xsl:with-param name="nodeSet" select="$nodeSet"/>
  348.                             <xsl:with-param name="CurrPos" select="$CurrPos + 1"/>
  349.                             <xsl:with-param name="x-adjust" select="$x-adjust"/>
  350.                             <xsl:with-param name="y-adjust" select="$y-adjust"/>
  351.                         </xsl:call-template>
  352.                     </xsl:variable>
  353.                     <xsl:call-template name="GetBigestWindows">
  354.                         <xsl:with-param name="Window1" select="$CurrNodeWindow"/>
  355.                         <xsl:with-param name="Window2" select="$FollowingWindow"/>
  356.                     </xsl:call-template>
  357.                 </xsl:variable>
  358.                 <xsl:value-of select="$CurrentWindow"/>
  359.             </xsl:otherwise>
  360.         </xsl:choose>
  361.     </xsl:template>
  362.     <xsl:template name="GetNodeWindow">
  363.         <xsl:param name="CurrNode"/>
  364.         <xsl:param name="x-adjust" select="0"/>
  365.         <xsl:param name="y-adjust" select="0"/>
  366.         <xsl:choose>
  367.             <xsl:when test="name($CurrNode)='draw:g'">
  368.                 <xsl:call-template name="GetWindowSize">
  369.                     <xsl:with-param name="nodeSet" select="$CurrNode/draw:*"/>
  370.                     <xsl:with-param name="x-adjust" select="$x-adjust"/>
  371.                     <xsl:with-param name="y-adjust" select="$y-adjust"/>
  372.                 </xsl:call-template>
  373.             </xsl:when>
  374.             <xsl:otherwise>
  375.                 <xsl:variable name="x">
  376.                     <xsl:call-template name="Add-With-Measure">
  377.                         <xsl:with-param name="value1" select="$CurrNode/@svg:x"/>
  378.                         <xsl:with-param name="value2" select="$x-adjust"/>
  379.                     </xsl:call-template>
  380.                 </xsl:variable>
  381.                 <xsl:variable name="y">
  382.                     <xsl:call-template name="Add-With-Measure">
  383.                         <xsl:with-param name="value1" select="$CurrNode/@svg:y"/>
  384.                         <xsl:with-param name="value2" select="$y-adjust"/>
  385.                     </xsl:call-template>
  386.                 </xsl:variable>
  387.                 <xsl:variable name="width">
  388.                     <xsl:call-template name="ConvertMeasure">
  389.                         <xsl:with-param name="value" select="$CurrNode/@svg:width"/>
  390.                         <xsl:with-param name="TargetMeasure" select="'in'"/>
  391.                     </xsl:call-template>
  392.                 </xsl:variable>
  393.                 <xsl:variable name="height">
  394.                     <xsl:choose>
  395.                         <xsl:when test="$CurrNode/@svg:height">
  396.                             <xsl:call-template name="ConvertMeasure">
  397.                                 <xsl:with-param name="value" select="$CurrNode/@svg:height"/>
  398.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  399.                             </xsl:call-template>
  400.                         </xsl:when>
  401.                         <xsl:when test="$CurrNode/@fo:min-height">
  402.                             <xsl:call-template name="ConvertMeasure">
  403.                                 <xsl:with-param name="value" select="$CurrNode/@fo:min-height"/>
  404.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  405.                             </xsl:call-template>
  406.                         </xsl:when>
  407.                         <xsl:otherwise>0</xsl:otherwise>
  408.                     </xsl:choose>
  409.                 </xsl:variable>
  410.                 <xsl:value-of select="concat('x1:' , $x, ';y1:' , $y, ';x2:' , string($x + $width), ';y2:', string($y + $height) ) "/>
  411.             </xsl:otherwise>
  412.         </xsl:choose>
  413.     </xsl:template>
  414.     <xsl:template name="GetBigestWindows">
  415.         <xsl:param name="Window1"/>
  416.         <xsl:param name="Window2"/>
  417.         <xsl:variable name="w1x1" select="substring-after( substring-before($Window1,';y1'),'x1:') "/>
  418.         <xsl:variable name="w2x1" select="substring-after( substring-before($Window2,';y1'),'x1:') "/>
  419.         <xsl:variable name="w1y1" select="substring-after( substring-before($Window1,';x2'),'y1:') "/>
  420.         <xsl:variable name="w2y1" select="substring-after( substring-before($Window2,';x2'),'y1:') "/>
  421.         <xsl:variable name="w1x2" select="substring-after( substring-before($Window1,';y2'),'x2:') "/>
  422.         <xsl:variable name="w2x2" select="substring-after( substring-before($Window2,';y2'),'x2:') "/>
  423.         <xsl:variable name="w1y2" select="substring-after( $Window1,';y2:') "/>
  424.         <xsl:variable name="w2y2" select="substring-after( $Window2,';y2:') "/>
  425.         <xsl:variable name="x1">
  426.             <xsl:choose>
  427.                 <xsl:when test="$w1x1 > $w2x1">
  428.                     <xsl:value-of select="$w2x1"/>
  429.                 </xsl:when>
  430.                 <xsl:otherwise>
  431.                     <xsl:value-of select="$w1x1"/>
  432.                 </xsl:otherwise>
  433.             </xsl:choose>
  434.         </xsl:variable>
  435.         <xsl:variable name="y1">
  436.             <xsl:choose>
  437.                 <xsl:when test="$w1y1 > $w2y1">
  438.                     <xsl:value-of select="$w2y1"/>
  439.                 </xsl:when>
  440.                 <xsl:otherwise>
  441.                     <xsl:value-of select="$w1y1"/>
  442.                 </xsl:otherwise>
  443.             </xsl:choose>
  444.         </xsl:variable>
  445.         <xsl:variable name="x2">
  446.             <xsl:choose>
  447.                 <xsl:when test="$w1x2 > $w2x2">
  448.                     <xsl:value-of select="$w1x2"/>
  449.                 </xsl:when>
  450.                 <xsl:otherwise>
  451.                     <xsl:value-of select="$w2x2"/>
  452.                 </xsl:otherwise>
  453.             </xsl:choose>
  454.         </xsl:variable>
  455.         <xsl:variable name="y2">
  456.             <xsl:choose>
  457.                 <xsl:when test="$w1y2 > $w2y2">
  458.                     <xsl:value-of select="$w1y2"/>
  459.                 </xsl:when>
  460.                 <xsl:otherwise>
  461.                     <xsl:value-of select="$w2y2"/>
  462.                 </xsl:otherwise>
  463.             </xsl:choose>
  464.         </xsl:variable>
  465.         <xsl:value-of select="concat('x1:' , $x1 , ';y1:' , $y1 , ';x2:' , $x2, ';y2:' , $y2)"/>
  466.     </xsl:template>
  467.     <!-- convert percent value to x%  numeric x/100 -->
  468.     <xsl:template name="ValueOfPercent">
  469.         <xsl:param name="value"/>
  470.         <xsl:choose>
  471.             <xsl:when test="contains($value, '%')">
  472.                 <xsl:value-of select="substring-before($value, '%') div 100"/>
  473.             </xsl:when>
  474.         </xsl:choose>
  475.     </xsl:template>
  476.     <xsl:template name="points2points">
  477.         <xsl:param name="input_points"/>
  478.         <xsl:param name="input_x"/>
  479.         <xsl:param name="input_y"/>
  480.         <xsl:param name="input_width"/>
  481.         <xsl:param name="input_height"/>
  482.         <xsl:param name="input_boxwidth"/>
  483.         <xsl:param name="input_boxheight"/>
  484.         <xsl:variable name="onepoint" select="substring ($input_points,1,string-length($input_points)  - string-length(substring-after($input_points,' '))  )"/>
  485.         <xsl:if test="substring-before($input_points,' ')">
  486.             <xsl:value-of select="round($input_x + (($input_boxwidth - substring-before($onepoint,',')) ) * $input_width div  $input_boxwidth)"/>
  487.             <xsl:value-of select="'pt,'"/>
  488.             <xsl:value-of select="round($input_y +  ((substring-after($onepoint,',')  ) ) * $input_height div $input_boxheight)"/>
  489.             <xsl:value-of select="'pt'"/>
  490.         </xsl:if>
  491.         <xsl:if test="string-length(substring($input_points,string-length($onepoint) + 1)) > 0">
  492.             <xsl:value-of select="','"/>
  493.             <xsl:call-template name="points2points">
  494.                 <xsl:with-param name="input_points" select="substring($input_points,string-length($onepoint) + 1)"/>
  495.                 <xsl:with-param name="input_x" select="$input_x"/>
  496.                 <xsl:with-param name="input_y" select="$input_y"/>
  497.                 <xsl:with-param name="input_width" select="$input_width"/>
  498.                 <xsl:with-param name="input_height" select="$input_height"/>
  499.                 <xsl:with-param name="input_boxwidth" select="$input_boxwidth"/>
  500.                 <xsl:with-param name="input_boxheight" select="$input_boxheight"/>
  501.             </xsl:call-template>
  502.         </xsl:if>
  503.     </xsl:template>
  504.     <xsl:template name="path2path">
  505.         <xsl:param name="input_points"/>
  506.         <xsl:param name="x_or_y" select="'x'"/>
  507.         <xsl:param name="input_x"/>
  508.         <xsl:param name="input_y"/>
  509.         <xsl:param name="input_width"/>
  510.         <xsl:param name="input_height"/>
  511.         <xsl:param name="input_boxwidth"/>
  512.         <xsl:param name="input_boxheight"/>
  513.         <xsl:variable name="space-pos" select="string-length($input_points) - string-length(substring-after($input_points,' '))"/>
  514.         <xsl:variable name="minus-pos" select="string-length($input_points) - string-length(substring-after($input_points,'-'))"/>
  515.         <xsl:variable name="m-pos" select="string-length($input_points) - string-length(substring-after($input_points,'m'))"/>
  516.         <xsl:variable name="c-pos" select="string-length($input_points) - string-length(substring-after($input_points,'c'))"/>
  517.         <xsl:variable name="e-pos" select="string-length($input_points) - string-length(substring-after($input_points,'e'))"/>
  518.         <xsl:variable name="min1">
  519.             <xsl:choose>
  520.                 <xsl:when test="$space-pos < $minus-pos">
  521.                     <xsl:value-of select="$space-pos"/>
  522.                 </xsl:when>
  523.                 <xsl:otherwise>
  524.                     <xsl:value-of select="$minus-pos"/>
  525.                 </xsl:otherwise>
  526.             </xsl:choose>
  527.         </xsl:variable>
  528.         <xsl:variable name="min2">
  529.             <xsl:choose>
  530.                 <xsl:when test="$m-pos < $min1">
  531.                     <xsl:value-of select="$m-pos"/>
  532.                 </xsl:when>
  533.                 <xsl:otherwise>
  534.                     <xsl:value-of select="$min1"/>
  535.                 </xsl:otherwise>
  536.             </xsl:choose>
  537.         </xsl:variable>
  538.         <xsl:variable name="min3">
  539.             <xsl:choose>
  540.                 <xsl:when test="$c-pos < $min2">
  541.                     <xsl:value-of select="$c-pos"/>
  542.                 </xsl:when>
  543.                 <xsl:otherwise>
  544.                     <xsl:value-of select="$min2"/>
  545.                 </xsl:otherwise>
  546.             </xsl:choose>
  547.         </xsl:variable>
  548.         <xsl:variable name="min4">
  549.             <xsl:choose>
  550.                 <xsl:when test="$e-pos < $min3">
  551.                     <xsl:value-of select="$e-pos"/>
  552.                 </xsl:when>
  553.                 <xsl:otherwise>
  554.                     <xsl:value-of select="$min3"/>
  555.                 </xsl:otherwise>
  556.             </xsl:choose>
  557.         </xsl:variable>
  558.         <xsl:variable name="min-special-char-pos" select="$min4"/>
  559.         <xsl:variable name="special-char" select="substring($input_points,$min-special-char-pos,1)"/>
  560.         <xsl:variable name="one-value" select="substring($input_points,1,$min-special-char-pos - 1)"/>
  561.         <xsl:variable name="left-points" select="substring($input_points,$min-special-char-pos + 1)"/>
  562.         <xsl:if test="not($special-char = 'm')">
  563.             <xsl:if test="$x_or_y = 'x'">
  564.                 <xsl:value-of select="round($input_x + $one-value * $input_width div  $input_boxwidth)"/>
  565.             </xsl:if>
  566.             <xsl:if test="$x_or_y = 'y'">
  567.                 <xsl:value-of select="round($input_y + $one-value * $input_height div $input_boxheight)"/>
  568.             </xsl:if>
  569.         </xsl:if>
  570.         <!-- output the separator-->
  571.         <xsl:choose>
  572.             <xsl:when test="$special-char = '-' or $special-char = ' ' ">
  573.                 <xsl:value-of select="','"/>
  574.             </xsl:when>
  575.             <xsl:otherwise>
  576.                 <xsl:value-of select="$special-char"/>
  577.             </xsl:otherwise>
  578.         </xsl:choose>
  579.         <xsl:variable name="next-xy">
  580.             <xsl:if test="$x_or_y = 'x'">
  581.                 <xsl:value-of select="'y'"/>
  582.             </xsl:if>
  583.             <xsl:if test="$x_or_y = 'y'">
  584.                 <xsl:value-of select="'x'"/>
  585.             </xsl:if>
  586.         </xsl:variable>
  587.         <xsl:if test="string-length($left-points) > 0">
  588.             <xsl:call-template name="path2path">
  589.                 <xsl:with-param name="input_points" select="$left-points"/>
  590.                 <xsl:with-param name="x_or_y" select="$next-xy"/>
  591.                 <xsl:with-param name="input_x" select="$input_x"/>
  592.                 <xsl:with-param name="input_y" select="$input_y"/>
  593.                 <xsl:with-param name="input_width" select="$input_width"/>
  594.                 <xsl:with-param name="input_height" select="$input_height"/>
  595.                 <xsl:with-param name="input_boxwidth" select="$input_boxwidth"/>
  596.                 <xsl:with-param name="input_boxheight" select="$input_boxheight"/>
  597.             </xsl:call-template>
  598.         </xsl:if>
  599.     </xsl:template>
  600.     <xsl:template name="get_dashstyle">
  601.         <xsl:param name="stroke-width" select="0.1"/>
  602.         <xsl:param name="style-name" select="@draw:style-name"/>
  603.         <xsl:variable name="graph-style" select="key('graphics-style', $style-name)/style:graphic-properties"/>
  604.         <xsl:variable name="dash-style" select="key('stroke-dash-style', $graph-style/@draw:stroke-dash)"/>
  605.         <xsl:variable name="stroke">
  606.             <xsl:choose>
  607.                 <xsl:when test="$graph-style/@draw:stroke">
  608.                     <xsl:value-of select="$graph-style/@draw:stroke"/>
  609.                 </xsl:when>
  610.                 <xsl:when test="$dash-style/@draw:stroke">
  611.                     <xsl:value-of select="$dash-style/@draw:stroke"/>
  612.                 </xsl:when>
  613.             </xsl:choose>
  614.         </xsl:variable>
  615.         <xsl:choose>
  616.             <xsl:when test="$stroke = 'solid' ">
  617.                 <xsl:value-of select="$stroke"/>
  618.             </xsl:when>
  619.             <xsl:when test="$stroke = 'dash'">
  620.                 <xsl:variable name="dots1">
  621.                     <xsl:choose>
  622.                         <xsl:when test="$graph-style/@draw:dots1">
  623.                             <xsl:value-of select="$graph-style/@draw:dots1"/>
  624.                         </xsl:when>
  625.                         <xsl:when test="$dash-style/@draw:dots1">
  626.                             <xsl:value-of select="$dash-style/@draw:dots1"/>
  627.                         </xsl:when>
  628.                         <xsl:otherwise>0</xsl:otherwise>
  629.                     </xsl:choose>
  630.                 </xsl:variable>
  631.                 <xsl:variable name="dots2">
  632.                     <xsl:choose>
  633.                         <xsl:when test="$graph-style/@draw:dots1">
  634.                             <xsl:value-of select="$graph-style/@draw:dots2"/>
  635.                         </xsl:when>
  636.                         <xsl:when test="$dash-style/@draw:dots1">
  637.                             <xsl:value-of select="$dash-style/@draw:dots2"/>
  638.                         </xsl:when>
  639.                         <xsl:otherwise>0</xsl:otherwise>
  640.                     </xsl:choose>
  641.                 </xsl:variable>
  642.                 <xsl:variable name="dots1-length">
  643.                     <xsl:choose>
  644.                         <xsl:when test="$graph-style/@draw:dots1-length">
  645.                             <xsl:value-of select="$graph-style/@draw:dots1-length"/>
  646.                         </xsl:when>
  647.                         <xsl:when test="$dash-style/@draw:dots1-length">
  648.                             <xsl:value-of select="$dash-style/@draw:dots1-length"/>
  649.                         </xsl:when>
  650.                         <xsl:otherwise>0</xsl:otherwise>
  651.                     </xsl:choose>
  652.                 </xsl:variable>
  653.                 <xsl:variable name="dots2-length">
  654.                     <xsl:choose>
  655.                         <xsl:when test="$graph-style/@draw:dots2-length">
  656.                             <xsl:value-of select="$graph-style/@draw:dots2-length"/>
  657.                         </xsl:when>
  658.                         <xsl:when test="$dash-style/@draw:dots2-length">
  659.                             <xsl:value-of select="$dash-style/@draw:dots2-length"/>
  660.                         </xsl:when>
  661.                         <xsl:otherwise>0</xsl:otherwise>
  662.                     </xsl:choose>
  663.                 </xsl:variable>
  664.                 <xsl:variable name="distance">
  665.                     <xsl:choose>
  666.                         <xsl:when test="$graph-style/@draw:distance">
  667.                             <xsl:value-of select="$graph-style/@draw:distance"/>
  668.                         </xsl:when>
  669.                         <xsl:when test="$dash-style/@draw:distance">
  670.                             <xsl:value-of select="$dash-style/@draw:distance"/>
  671.                         </xsl:when>
  672.                         <xsl:otherwise>0</xsl:otherwise>
  673.                     </xsl:choose>
  674.                 </xsl:variable>
  675.                 <xsl:variable name="dot1-step">
  676.                     <xsl:choose>
  677.                         <xsl:when test="contains($dots1-length,'%')">
  678.                             <xsl:variable name="dots-percent">
  679.                                 <xsl:call-template name="ValueOfPercent">
  680.                                     <xsl:with-param name="value" select="$dots1-length"/>
  681.                                 </xsl:call-template>
  682.                             </xsl:variable>
  683.                             <xsl:value-of select="round($dots-percent)"/>
  684.                         </xsl:when>
  685.                         <xsl:when test="contains($dots1-length , 'in' ) and $stroke-width > 0">
  686.                             <xsl:value-of select="round( substring-before ($dots1-length,'in' ) div $stroke-width )"/>
  687.                         </xsl:when>
  688.                         <xsl:otherwise>0</xsl:otherwise>
  689.                     </xsl:choose>
  690.                 </xsl:variable>
  691.                 <xsl:variable name="dot2-step">
  692.                     <xsl:choose>
  693.                         <xsl:when test="contains($dots2-length,'%')">
  694.                             <xsl:variable name="dots-percent">
  695.                                 <xsl:call-template name="ValueOfPercent">
  696.                                     <xsl:with-param name="value" select="$dots2-length"/>
  697.                                 </xsl:call-template>
  698.                             </xsl:variable>
  699.                             <xsl:value-of select="round($dots-percent)"/>
  700.                         </xsl:when>
  701.                         <xsl:when test="contains($dots2-length,'in') and $stroke-width > 0">
  702.                             <xsl:value-of select="round(substring-before($dots2-length,'in') div $stroke-width)"/>
  703.                         </xsl:when>
  704.                         <xsl:otherwise>0</xsl:otherwise>
  705.                     </xsl:choose>
  706.                 </xsl:variable>
  707.                 <xsl:variable name="distance-step">
  708.                     <xsl:choose>
  709.                         <xsl:when test="contains($distance,'%')">
  710.                             <xsl:variable name="dots-percent">
  711.                                 <xsl:call-template name="ValueOfPercent">
  712.                                     <xsl:with-param name="value" select="$distance"/>
  713.                                 </xsl:call-template>
  714.                             </xsl:variable>
  715.                             <xsl:value-of select="round($dots-percent)"/>
  716.                         </xsl:when>
  717.                         <xsl:when test="contains($distance,'in') and $stroke-width > 0">
  718.                             <xsl:value-of select="round(substring-before($distance,'in') div $stroke-width)"/>
  719.                         </xsl:when>
  720.                         <xsl:otherwise>1</xsl:otherwise>
  721.                     </xsl:choose>
  722.                 </xsl:variable>
  723.                 <xsl:variable name="dashstyle">
  724.                     <xsl:choose>
  725.                         <xsl:when test="$dots1 = 1 and $dots2 = 1 and $dot1-step = 0 and $dot2-step = 0 and $distance-step = 0">
  726.                             <xsl:value-of select="'ShortDot'"/>
  727.                         </xsl:when>
  728.                         <xsl:when test="$dots2 = 0 and $dot1-step = 0 and $dot2-step = 0 and $distance-step > 0">
  729.                             <xsl:value-of select="concat('0 ', $distance-step)"/>
  730.                         </xsl:when>
  731.                         <xsl:otherwise>
  732.                             <xsl:call-template name="create_dashstyle">
  733.                                 <xsl:with-param name="dot-count" select="$dots1"/>
  734.                                 <xsl:with-param name="dot-step" select="$dot1-step"/>
  735.                                 <xsl:with-param name="distance-step" select="$distance-step"/>
  736.                             </xsl:call-template>
  737.                             <xsl:value-of select="' '"/>
  738.                             <xsl:call-template name="create_dashstyle">
  739.                                 <xsl:with-param name="dot-count" select="$dots2"/>
  740.                                 <xsl:with-param name="dot-step" select="$dot2-step"/>
  741.                                 <xsl:with-param name="distance-step" select="$distance-step"/>
  742.                             </xsl:call-template>
  743.                         </xsl:otherwise>
  744.                     </xsl:choose>
  745.                 </xsl:variable>
  746.                 <xsl:value-of select="$dashstyle"/>
  747.             </xsl:when>
  748.         </xsl:choose>
  749.     </xsl:template>
  750.     <xsl:template name="create_dashstyle">
  751.         <xsl:param name="dot-count"/>
  752.         <xsl:param name="dot-step"/>
  753.         <xsl:param name="distance-step"/>
  754.         <xsl:if test="$dot-count > 0">
  755.             <xsl:value-of select="concat($dot-step, ' ' , $distance-step )"/>
  756.             <xsl:if test="$dot-count - 1 > 0">
  757.                 <xsl:value-of select="' '"/>
  758.                 <xsl:call-template name="create_dashstyle">
  759.                     <xsl:with-param name="dot-count" select="$dot-count - 1"/>
  760.                     <xsl:with-param name="dot-step" select="$dot-step"/>
  761.                     <xsl:with-param name="distance-step" select="$distance-step"/>
  762.                 </xsl:call-template>
  763.             </xsl:if>
  764.         </xsl:if>
  765.     </xsl:template>
  766.     <xsl:template name="get_borderstyle">
  767.         <xsl:param name="border"/>
  768.         <xsl:param name="border-line-width"/>
  769.         <xsl:choose>
  770.             <xsl:when test="contains($border,'solid')">
  771.                 <xsl:variable name="strokeweight">
  772.                     <xsl:call-template name="ConvertMeasure">
  773.                         <xsl:with-param name="value" select="substring-before($border, ' ')"/>
  774.                         <xsl:with-param name="TargetMeasure" select="'pt'"/>
  775.                     </xsl:call-template>
  776.                 </xsl:variable>
  777.                 <xsl:value-of select="concat ( 'strokeweight:', $strokeweight)"/>
  778.             </xsl:when>
  779.             <xsl:when test="contains($border,'double')">
  780.                 <xsl:variable name="outside">
  781.                     <xsl:call-template name="ConvertMeasure">
  782.                         <xsl:with-param name="value" select="substring-after(substring-after($border-line-width, ' ') , ' ')"/>
  783.                         <xsl:with-param name="TargetMeasure" select="'pt'"/>
  784.                     </xsl:call-template>
  785.                 </xsl:variable>
  786.                 <xsl:variable name="inside">
  787.                     <xsl:call-template name="ConvertMeasure">
  788.                         <xsl:with-param name="value" select="substring-before($border-line-width, ' ')"/>
  789.                         <xsl:with-param name="TargetMeasure" select="'pt'"/>
  790.                     </xsl:call-template>
  791.                 </xsl:variable>
  792.                 <xsl:variable name="space">
  793.                     <xsl:call-template name="ConvertMeasure">
  794.                         <xsl:with-param name="value" select="substring-before(substring-after($border-line-width, ' ') , ' ')"/>
  795.                         <xsl:with-param name="TargetMeasure" select="'pt'"/>
  796.                     </xsl:call-template>
  797.                 </xsl:variable>
  798.                 <xsl:variable name="linestyle">
  799.                     <xsl:choose>
  800.                         <xsl:when test="$outside = $inside">
  801.                             <xsl:value-of select="'thinThin'"/>
  802.                         </xsl:when>
  803.                         <xsl:when test="$outside > $inside">
  804.                             <xsl:value-of select="'thickThin'"/>
  805.                         </xsl:when>
  806.                         <xsl:when test="$outside < $inside">
  807.                             <xsl:value-of select="'thinThick'"/>
  808.                         </xsl:when>
  809.                     </xsl:choose>
  810.                 </xsl:variable>
  811.                 <xsl:variable name="strokeweight" select="$inside + $outside + $space"/>
  812.                 <xsl:value-of select="concat( 'linestyle:' , $linestyle , ';' , 'strokeweight:' , $strokeweight )"/>
  813.             </xsl:when>
  814.         </xsl:choose>
  815.     </xsl:template>
  816.     <xsl:template name="DrawElements">
  817.         <xsl:param name="TargetMeasure" select="pt"/>
  818.         <xsl:param name="x-adjust" select="0"/>
  819.         <xsl:param name="y-adjust" select="0"/>
  820.         <xsl:param name="force-draw" select="'false'"/>
  821.         <xsl:param name="shape-type"/>
  822.         <xsl:variable name="MeasureMark">
  823.             <xsl:choose>
  824.                 <xsl:when test="$TargetMeasure = 'twip'"/>
  825.                 <xsl:otherwise>
  826.                     <xsl:value-of select="$TargetMeasure"/>
  827.                 </xsl:otherwise>
  828.             </xsl:choose>
  829.         </xsl:variable>
  830.         <xsl:variable name="drawtextstyle" select="@draw:text-style-name"/>
  831.         <xsl:variable name="org-z-index">
  832.             <xsl:choose>
  833.                 <xsl:when test="@draw:z-index">
  834.                     <xsl:value-of select="number(concat('0',@draw:z-index))"/>
  835.                 </xsl:when>
  836.                 <xsl:when test="parent::draw:frame/@draw:z-index">
  837.                     <xsl:value-of select="number(concat('0',parent::draw:frame/@draw:z-index))"/>
  838.                 </xsl:when>
  839.                 <xsl:otherwise>0</xsl:otherwise>
  840.             </xsl:choose>
  841.         </xsl:variable>
  842.         <xsl:variable name="run-though" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@style:run-through"/>
  843.         <xsl:variable name="org-wrap" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@style:wrap"/>
  844.         <xsl:variable name="draw-name">
  845.             <xsl:choose>
  846.                 <xsl:when test="string-length(@draw:name) = 0">
  847.                     <xsl:value-of select="translate(ancestor::draw:frame/@draw:name, ':/',  '__')"/>
  848.                 </xsl:when>
  849.                 <xsl:otherwise>
  850.                     <xsl:value-of select="translate(@draw:name, ':/',  '__')"/>
  851.                 </xsl:otherwise>
  852.             </xsl:choose>
  853.         </xsl:variable>
  854.         <xsl:variable name="style_name2key">
  855.             <xsl:choose>
  856.                 <xsl:when test="@draw:style-name">
  857.                     <xsl:value-of select="@draw:style-name"/>
  858.                 </xsl:when>
  859.                 <xsl:otherwise>
  860.                     <xsl:if test="ancestor::draw:frame/@draw:style-name">
  861.                         <xsl:value-of select="ancestor::draw:frame/@draw:style-name"/>
  862.                     </xsl:if>
  863.                 </xsl:otherwise>
  864.             </xsl:choose>
  865.         </xsl:variable>
  866.         <xsl:variable name="draw-fill-type" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fill"/>
  867.         <xsl:variable name="draw-gradient-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fill-gradient-name"/>
  868.         <xsl:variable name="horizontal-pos" select="key('graphics-style', $style_name2key)/style:graphic-properties/@style:horizontal-pos"/>
  869.         <!--horizontal-pos attribute is for the placement of all the drawing elements-->
  870.         <xsl:variable name="fill-image-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fill-image-name"/>
  871.         <xsl:if test="$draw-fill-type = 'bitmap' ">
  872.             <xsl:element name="w:binData">
  873.                 <xsl:attribute name="w:name">
  874.                     <xsl:value-of select="concat( 'wordml://', $fill-image-name)"/>
  875.                 </xsl:attribute>
  876.                 <xsl:value-of select="translate(key('fill-image',$fill-image-name)/office:binary-data/text(),' ','' ) "/>
  877.                 <!-- xsl:value-of select="office:binary-data/text()"/ -->
  878.             </xsl:element>
  879.         </xsl:if>
  880.         <xsl:variable name="z-index">
  881.             <xsl:choose>
  882.                 <xsl:when test="$run-though='foreground'">
  883.                     <!-- make sure z-index >=0 -->
  884.                     <xsl:choose>
  885.                         <xsl:when test="$org-z-index < 0">0</xsl:when>
  886.                         <xsl:otherwise>
  887.                             <xsl:value-of select="$org-z-index"/>
  888.                         </xsl:otherwise>
  889.                     </xsl:choose>
  890.                 </xsl:when>
  891.                 <xsl:when test="$run-though='background'">
  892.                     <!-- make sure z-index < 0 -->
  893.                     <xsl:choose>
  894.                         <xsl:when test="$org-z-index < 0">
  895.                             <xsl:value-of select="$org-z-index"/>
  896.                         </xsl:when>
  897.                         <xsl:otherwise>
  898.                             <xsl:value-of select="$org-z-index - 10"/>
  899.                         </xsl:otherwise>
  900.                     </xsl:choose>
  901.                 </xsl:when>
  902.                 <xsl:otherwise>0</xsl:otherwise>
  903.             </xsl:choose>
  904.         </xsl:variable>
  905.         <xsl:variable name="wrap">
  906.             <xsl:choose>
  907.                 <xsl:when test="@text:anchor-type='as-char' ">none</xsl:when>
  908.                 <xsl:when test="$org-wrap='dynamic'">tight</xsl:when>
  909.                 <xsl:when test="$org-wrap='parallel'">square</xsl:when>
  910.             </xsl:choose>
  911.         </xsl:variable>
  912.         <xsl:variable name="ooshapename" select="substring-after(name(),':')"/>
  913.         <xsl:variable name="element-name">
  914.             <xsl:choose>
  915.                 <xsl:when test="$ooshapename='rect'">v:rect</xsl:when>
  916.                 <xsl:when test="$ooshapename='ellipse' and not(string-length(@draw:kind) > 0)">v:oval</xsl:when>
  917.                 <xsl:when test="$ooshapename='ellipse' and string-length(@draw:kind) > 0">v:arc</xsl:when>
  918.                 <xsl:when test="$ooshapename='circle' and string-length(@draw:kind) > 0">v:arc</xsl:when>
  919.                 <xsl:when test="$ooshapename='line'">v:line</xsl:when>
  920.                 <xsl:when test="$ooshapename='polyline'">v:polyline</xsl:when>
  921.                 <xsl:when test="$ooshapename='polygon'">v:polyline</xsl:when>
  922.                 <xsl:when test="$ooshapename='text-box'">v:shape</xsl:when>
  923.                 <xsl:when test="$ooshapename='image'">v:shape</xsl:when>
  924.                 <xsl:when test="$ooshapename='frame'">v:shape</xsl:when>
  925.                 <xsl:when test="$ooshapename='path'">v:shape</xsl:when>
  926.                 <!-- This caption is not the "Caption", it's GUI name is Callouts-->
  927.                 <xsl:when test="$ooshapename='caption'">v:shape</xsl:when>
  928.                 <xsl:when test="$ooshapename='custom-shape' and draw:enhanced-geometry[1]/@draw:predefined-type = 'non-primitive' ">v:shape</xsl:when>
  929.                 <xsl:when test="$ooshapename='custom-shape' and draw:enhanced-geometry[1]/@draw:predefined-type = 'round-rectangle' ">v:roundrect</xsl:when>
  930.                 <xsl:when test="$ooshapename='custom-shape' and draw:enhanced-geometry[1]/@draw:predefined-type = 'rectangle' ">v:rect</xsl:when>
  931.                 <xsl:when test="$ooshapename='custom-shape' and draw:enhanced-geometry[1]/@draw:predefined-type = 'ellipse' ">v:oval</xsl:when>
  932.                 <xsl:when test="$ooshapename='custom-shape'">v:shape</xsl:when>
  933.             </xsl:choose>
  934.         </xsl:variable>
  935.         <xsl:variable name="ms-shape-type">
  936.             <xsl:choose>
  937.                 <xsl:when test="string-length($shape-type) > 0">
  938.                     <xsl:value-of select="$shape-type"/>
  939.                 </xsl:when>
  940.                 <xsl:when test="$ooshapename='custom-shape' ">
  941.                     <xsl:call-template name="ooo_custom_draw2ms_word_draw_map">
  942.                         <xsl:with-param name="ooo_predefined_type" select="draw:enhanced-geometry[1]/@draw:predefined-type"/>
  943.                     </xsl:call-template>
  944.                 </xsl:when>
  945.             </xsl:choose>
  946.         </xsl:variable>
  947.         <xsl:variable name="real-x-adjust">
  948.             <xsl:call-template name="ConvertMeasure">
  949.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  950.                 <xsl:with-param name="value" select="concat($x-adjust,'in')"/>
  951.             </xsl:call-template>
  952.         </xsl:variable>
  953.         <xsl:variable name="real-y-adjust">
  954.             <xsl:call-template name="ConvertMeasure">
  955.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  956.                 <xsl:with-param name="value" select="concat($y-adjust,'in')"/>
  957.             </xsl:call-template>
  958.         </xsl:variable>
  959.         <xsl:variable name="org-x">
  960.             <xsl:call-template name="ConvertMeasure">
  961.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  962.                 <xsl:with-param name="value" select="@svg:x"/>
  963.             </xsl:call-template>
  964.         </xsl:variable>
  965.         <xsl:variable name="org-y">
  966.             <xsl:call-template name="ConvertMeasure">
  967.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  968.                 <xsl:with-param name="value" select="@svg:y"/>
  969.             </xsl:call-template>
  970.         </xsl:variable>
  971.         <xsl:variable name="pagemaster" select="key('master-page','Standard')/@style:page-layout-name"/>
  972.         <xsl:variable name="leftmargin-pt">
  973.             <xsl:call-template name="ConvertMeasure">
  974.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  975.                 <xsl:with-param name="value" select="key('page-layout',$pagemaster)/style:page-layout-properties/@fo:margin-left"/>
  976.             </xsl:call-template>
  977.         </xsl:variable>
  978.         <xsl:variable name="topmargin-pt">
  979.             <xsl:call-template name="ConvertMeasure">
  980.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  981.                 <xsl:with-param name="value" select="key('page-layout',$pagemaster)/style:page-layout-properties/@fo:margin-top"/>
  982.             </xsl:call-template>
  983.         </xsl:variable>
  984.         <!-- addjust the x and y values of the page archored objects-->
  985.         <xsl:variable name="x">
  986.             <xsl:choose>
  987.                 <xsl:when test="@text:anchor-type='page' or ancestor::draw:*/@text:anchor-type='page'">
  988.                     <xsl:value-of select="$org-x + $real-x-adjust - $leftmargin-pt"/>
  989.                 </xsl:when>
  990.                 <xsl:otherwise>
  991.                     <xsl:value-of select="$org-x + $real-x-adjust"/>
  992.                 </xsl:otherwise>
  993.             </xsl:choose>
  994.         </xsl:variable>
  995.         <xsl:variable name="y">
  996.             <xsl:choose>
  997.                 <xsl:when test="@text:anchor-type='page' or ancestor::draw:*/@text:anchor-type='page'">
  998.                     <xsl:value-of select="$org-y + $real-y-adjust - $topmargin-pt"/>
  999.                 </xsl:when>
  1000.                 <xsl:otherwise>
  1001.                     <xsl:value-of select="$org-y + $real-y-adjust"/>
  1002.                 </xsl:otherwise>
  1003.             </xsl:choose>
  1004.         </xsl:variable>
  1005.         <xsl:variable name="width">
  1006.             <xsl:variable name="width-tmp">
  1007.                 <xsl:choose>
  1008.                     <xsl:when test="@svg:width">
  1009.                         <xsl:value-of select="@svg:width"/>
  1010.                     </xsl:when>
  1011.                     <xsl:when test="not(string-length(parent::draw:frame/@svg:width) = 0)">
  1012.                         <xsl:value-of select="parent::draw:frame/@svg:width"/>
  1013.                     </xsl:when>
  1014.                     <xsl:when test="string-length(@svg:width) = 0 and ancestor::draw:frame">
  1015.                         <xsl:value-of select="ancestor::draw:frame/@svg:width"/>
  1016.                     </xsl:when>
  1017.                     <xsl:otherwise>
  1018.                         <xsl:value-of select="@svg:width"/>
  1019.                     </xsl:otherwise>
  1020.                 </xsl:choose>
  1021.             </xsl:variable>
  1022.             <xsl:call-template name="ConvertMeasure">
  1023.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1024.                 <xsl:with-param name="value" select="$width-tmp"/>
  1025.             </xsl:call-template>
  1026.         </xsl:variable>
  1027.         <xsl:variable name="height">
  1028.             <xsl:choose>
  1029.                 <xsl:when test="@svg:height">
  1030.                     <xsl:call-template name="ConvertMeasure">
  1031.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1032.                         <xsl:with-param name="value" select="@svg:height"/>
  1033.                     </xsl:call-template>
  1034.                 </xsl:when>
  1035.                 <xsl:when test="not(string-length(parent::draw:frame/@svg:height) = 0)">
  1036.                     <xsl:call-template name="ConvertMeasure">
  1037.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1038.                         <xsl:with-param name="value" select="parent::draw:frame/@svg:height"/>
  1039.                     </xsl:call-template>
  1040.                 </xsl:when>
  1041.                 <xsl:when test="@fo:min-height and string-length(text:p/text()) = 0 and not(text:p/draw:*)">
  1042.                     <xsl:call-template name="ConvertMeasure">
  1043.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1044.                         <xsl:with-param name="value" select="@fo:min-height"/>
  1045.                     </xsl:call-template>
  1046.                 </xsl:when>
  1047.                 <xsl:otherwise>0</xsl:otherwise>
  1048.             </xsl:choose>
  1049.         </xsl:variable>
  1050.         <xsl:variable name="borderstyle">
  1051.             <xsl:call-template name="get_borderstyle">
  1052.                 <xsl:with-param name="border" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@fo:border"/>
  1053.                 <xsl:with-param name="border-line-width" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@style:border-line-width"/>
  1054.             </xsl:call-template>
  1055.         </xsl:variable>
  1056.         <xsl:variable name="stroke-weight-in-inch" select="number(concat('0',translate(key('graphics-style', @draw:style-name)/style:graphic-properties/@svg:stroke-width ,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','') ))"/>
  1057.         <xsl:variable name="stroke-weight">
  1058.             <xsl:choose>
  1059.                 <xsl:when test="contains($borderstyle , 'strokeweight')">
  1060.                     <xsl:call-template name="ConvertMeasure">
  1061.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1062.                         <xsl:with-param name="value" select="concat( substring-after($borderstyle, 'strokeweight:') , 'pt')"/>
  1063.                     </xsl:call-template>
  1064.                 </xsl:when>
  1065.                 <xsl:otherwise>
  1066.                     <xsl:call-template name="ConvertMeasure">
  1067.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1068.                         <xsl:with-param name="value" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@svg:stroke-width"/>
  1069.                     </xsl:call-template>
  1070.                 </xsl:otherwise>
  1071.             </xsl:choose>
  1072.         </xsl:variable>
  1073.         <xsl:variable name="linestyle">
  1074.             <xsl:if test="contains($borderstyle , 'strokeweight')">
  1075.                 <xsl:value-of select="substring-before( substring-after($borderstyle, 'linestyle:') , ';strokeweight')"/>
  1076.             </xsl:if>
  1077.         </xsl:variable>
  1078.         <xsl:variable name="stroked">
  1079.             <xsl:if test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:stroke = 'none'">
  1080.                 <xsl:value-of select="'f'"/>
  1081.             </xsl:if>
  1082.         </xsl:variable>
  1083.         <xsl:variable name="dashstyle">
  1084.             <xsl:call-template name="get_dashstyle">
  1085.                 <xsl:with-param name="stroke-width" select="$stroke-weight-in-inch"/>
  1086.                 <xsl:with-param name="style-name" select="@draw:style-name"/>
  1087.             </xsl:call-template>
  1088.         </xsl:variable>
  1089.         <xsl:variable name="start-arrow">
  1090.             <xsl:choose>
  1091.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end">
  1092.                     <xsl:call-template name="MapArrowStyle">
  1093.                         <xsl:with-param name="arrow-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end"/>
  1094.                     </xsl:call-template>
  1095.                 </xsl:when>
  1096.             </xsl:choose>
  1097.         </xsl:variable>
  1098.         <xsl:variable name="end-arrow">
  1099.             <xsl:choose>
  1100.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start">
  1101.                     <xsl:call-template name="MapArrowStyle">
  1102.                         <xsl:with-param name="arrow-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start"/>
  1103.                     </xsl:call-template>
  1104.                 </xsl:when>
  1105.             </xsl:choose>
  1106.         </xsl:variable>
  1107.         <xsl:variable name="start-arrow-length">
  1108.             <xsl:choose>
  1109.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end">
  1110.                     <xsl:call-template name="GetArrowLength">
  1111.                         <xsl:with-param name="arrow-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end"/>
  1112.                         <xsl:with-param name="arrow-width" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end-width"/>
  1113.                     </xsl:call-template>
  1114.                 </xsl:when>
  1115.             </xsl:choose>
  1116.         </xsl:variable>
  1117.         <xsl:variable name="start-arrow-width">
  1118.             <xsl:choose>
  1119.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end">
  1120.                     <xsl:call-template name="GetArrowWidth">
  1121.                         <xsl:with-param name="arrow-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end"/>
  1122.                         <xsl:with-param name="arrow-width" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-end-width"/>
  1123.                     </xsl:call-template>
  1124.                 </xsl:when>
  1125.             </xsl:choose>
  1126.         </xsl:variable>
  1127.         <xsl:variable name="end-arrow-length">
  1128.             <xsl:choose>
  1129.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start">
  1130.                     <xsl:call-template name="GetArrowLength">
  1131.                         <xsl:with-param name="arrow-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start"/>
  1132.                         <xsl:with-param name="arrow-width" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start-width"/>
  1133.                     </xsl:call-template>
  1134.                 </xsl:when>
  1135.             </xsl:choose>
  1136.         </xsl:variable>
  1137.         <xsl:variable name="end-arrow-width">
  1138.             <xsl:choose>
  1139.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start">
  1140.                     <xsl:call-template name="GetArrowWidth">
  1141.                         <xsl:with-param name="arrow-name" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start"/>
  1142.                         <xsl:with-param name="arrow-width" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:marker-start-width"/>
  1143.                     </xsl:call-template>
  1144.                 </xsl:when>
  1145.             </xsl:choose>
  1146.         </xsl:variable>
  1147.         <xsl:variable name="stroke-color">
  1148.             <xsl:choose>
  1149.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@svg:stroke-color">
  1150.                     <xsl:value-of select="key('graphics-style', @draw:style-name)/style:graphic-properties/@svg:stroke-color"/>
  1151.                 </xsl:when>
  1152.                 <xsl:when test="contains(key('graphics-style', @draw:style-name)/style:graphic-properties/@fo:border, '#')">
  1153.                     <xsl:value-of select="concat('#',  substring-after(key('graphics-style', @draw:style-name)/style:graphic-properties/@fo:border, '#') )"/>
  1154.                 </xsl:when>
  1155.             </xsl:choose>
  1156.         </xsl:variable>
  1157.         <xsl:variable name="stroke-opacity">
  1158.             <xsl:call-template name="ValueOfPercent">
  1159.                 <xsl:with-param name="value" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@svg:stroke-opacity"/>
  1160.             </xsl:call-template>
  1161.         </xsl:variable>
  1162.         <xsl:variable name="fill-color">
  1163.             <xsl:choose>
  1164.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fill-color">
  1165.                     <xsl:value-of select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fill-color"/>
  1166.                 </xsl:when>
  1167.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-style">black</xsl:when>
  1168.                 <xsl:when test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fill = 'none'"/>
  1169.                 <xsl:when test="$draw-fill-type = 'gradient' ">
  1170.                     <xsl:value-of select="key('draw-gradient',$draw-gradient-name)/@draw:end-color "/>
  1171.                 </xsl:when>
  1172.                 <!-- for these need fill, set the default color we used in oo-->
  1173.                 <xsl:when test="name()='draw:polygon' or name()='draw:custom-shape'  or name() = 'draw:rect' or (name() = 'draw:ellipse' and not(  @draw:kind='arc') )">#00B8FF</xsl:when>
  1174.             </xsl:choose>
  1175.         </xsl:variable>
  1176.         <xsl:variable name="position">
  1177.             <xsl:value-of select="concat('left:', $x ,$MeasureMark ,  ';top:' , $y ,$MeasureMark  , ';width:', $width ,$MeasureMark )"/>
  1178.             <xsl:if test="not($height = 0)">
  1179.                 <xsl:value-of select="concat(';height:', $height ,$MeasureMark )"/>
  1180.             </xsl:if>
  1181.         </xsl:variable>
  1182.         <xsl:variable name="flip">
  1183.             <xsl:choose>
  1184.                 <xsl:when test="@text:anchor-type='as-char' and $ooshapename='line'"/>
  1185.                 <xsl:when test="$ooshapename='image'"/>
  1186.                 <xsl:when test="$ooshapename='path'"/>
  1187.                 <xsl:when test="$ooshapename='caption'"/>
  1188.                 <xsl:when test="@draw:kind = 'arc' or @draw:kind = 'cut' or @draw:kind = 'section'"/>
  1189.                 <xsl:when test="$ooshapename='custom-shape'"/>
  1190.                 <xsl:otherwise>flip:x</xsl:otherwise>
  1191.             </xsl:choose>
  1192.         </xsl:variable>
  1193.         <xsl:variable name="absolute">
  1194.             <xsl:choose>
  1195.                 <xsl:when test="ancestor::draw:a"/>
  1196.                 <xsl:when test="@text:anchor-type = 'as-char' or @text:anchor-type = 'to-char'"/>
  1197.                 <xsl:when test="parent::draw:frame/@text:anchor-type = 'as-char' or parent::draw:frame/@text:anchor-type = 'to-char'"/>
  1198.                 <xsl:otherwise>position:absolute</xsl:otherwise>
  1199.             </xsl:choose>
  1200.         </xsl:variable>
  1201.         <xsl:variable name="anchorlock">
  1202.             <xsl:choose>
  1203.                 <xsl:when test="@text:anchor-type = 'as-char' or @text:anchor-type = 'to-char'">has</xsl:when>
  1204.                 <xsl:otherwise/>
  1205.             </xsl:choose>
  1206.         </xsl:variable>
  1207.         <!-- start line special -->
  1208.         <xsl:variable name="org-x1">
  1209.             <xsl:call-template name="ConvertMeasure">
  1210.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1211.                 <xsl:with-param name="value" select="@svg:x1"/>
  1212.             </xsl:call-template>
  1213.         </xsl:variable>
  1214.         <xsl:variable name="org-y1">
  1215.             <xsl:call-template name="ConvertMeasure">
  1216.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1217.                 <xsl:with-param name="value" select="@svg:y1"/>
  1218.             </xsl:call-template>
  1219.         </xsl:variable>
  1220.         <xsl:variable name="org-x2">
  1221.             <xsl:call-template name="ConvertMeasure">
  1222.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1223.                 <xsl:with-param name="value" select="@svg:x2"/>
  1224.             </xsl:call-template>
  1225.         </xsl:variable>
  1226.         <xsl:variable name="org-y2">
  1227.             <xsl:call-template name="ConvertMeasure">
  1228.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1229.                 <xsl:with-param name="value" select="@svg:y2"/>
  1230.             </xsl:call-template>
  1231.         </xsl:variable>
  1232.         <xsl:variable name="x1">
  1233.             <xsl:choose>
  1234.                 <xsl:when test="@text:anchor-type='page' or ancestor::draw:*/@text:anchor-type='page'">
  1235.                     <xsl:value-of select="$org-x1 + $real-x-adjust - $leftmargin-pt"/>
  1236.                 </xsl:when>
  1237.                 <xsl:otherwise>
  1238.                     <xsl:value-of select="$org-x1 + $real-x-adjust"/>
  1239.                 </xsl:otherwise>
  1240.             </xsl:choose>
  1241.         </xsl:variable>
  1242.         <xsl:variable name="y1">
  1243.             <xsl:choose>
  1244.                 <xsl:when test="@text:anchor-type='page' or ancestor::draw:*/@text:anchor-type='page'">
  1245.                     <xsl:value-of select="$org-y1 + $real-y-adjust - $topmargin-pt"/>
  1246.                 </xsl:when>
  1247.                 <xsl:otherwise>
  1248.                     <xsl:value-of select="$org-y1 + $real-y-adjust"/>
  1249.                 </xsl:otherwise>
  1250.             </xsl:choose>
  1251.         </xsl:variable>
  1252.         <xsl:variable name="x2">
  1253.             <xsl:choose>
  1254.                 <xsl:when test="@text:anchor-type='page' or ancestor::draw:*/@text:anchor-type='page'">
  1255.                     <xsl:value-of select="$org-x2  + $real-x-adjust - $leftmargin-pt"/>
  1256.                 </xsl:when>
  1257.                 <xsl:otherwise>
  1258.                     <xsl:value-of select="$org-x2 + $real-x-adjust"/>
  1259.                 </xsl:otherwise>
  1260.             </xsl:choose>
  1261.         </xsl:variable>
  1262.         <xsl:variable name="y2">
  1263.             <xsl:choose>
  1264.                 <xsl:when test="@text:anchor-type='page' or ancestor::draw:*/@text:anchor-type='page'">
  1265.                     <xsl:value-of select="$org-y2 + $real-y-adjust - $topmargin-pt"/>
  1266.                 </xsl:when>
  1267.                 <xsl:otherwise>
  1268.                     <xsl:value-of select="$org-y2 + $real-y-adjust"/>
  1269.                 </xsl:otherwise>
  1270.             </xsl:choose>
  1271.         </xsl:variable>
  1272.         <!-- end line special -->
  1273.         <xsl:variable name="relative">
  1274.             <xsl:choose>
  1275.                 <xsl:when test="@text:anchor-type = 'as-char' or @text:anchor-type = 'to-char'">mso-position-horizontal-relative:char;mso-position-vertical-relative:line</xsl:when>
  1276.                 <xsl:when test="parent::draw:frame/@text:anchor-type = 'as-char' or parent::draw:frame/@text:anchor-type = 'to-char'">mso-position-horizontal-relative:char;mso-position-vertical-relative:line</xsl:when>
  1277.                 <xsl:otherwise/>
  1278.             </xsl:choose>
  1279.         </xsl:variable>
  1280.         <xsl:variable name="style">
  1281.             <xsl:choose>
  1282.                 <xsl:when test="$wrap='none'"/>
  1283.                 <xsl:otherwise>
  1284.                     <xsl:if test="string-length($absolute) > 0">
  1285.                         <xsl:value-of select="concat($absolute, ';')"/>
  1286.                     </xsl:if>
  1287.                     <xsl:value-of select="concat('z-index:', $z-index, ';')"/>
  1288.                 </xsl:otherwise>
  1289.             </xsl:choose>
  1290.             <xsl:if test="string-length($flip) > 0">
  1291.                 <xsl:value-of select="concat($flip,';')"/>
  1292.             </xsl:if>
  1293.             <xsl:if test="not($ooshapename = 'line')">
  1294.                 <xsl:value-of select="concat($position,';')"/>
  1295.             </xsl:if>
  1296.             <xsl:if test="ancestor::draw:frame and name()='draw:text-box'">
  1297.                 <xsl:if test="string-length($horizontal-pos) > 0">
  1298.                     <xsl:value-of select="concat('mso-position-horizontal:',$horizontal-pos,';')"/>
  1299.                 </xsl:if>
  1300.             </xsl:if>
  1301.             <xsl:if test="string-length($relative) > 0">
  1302.                 <xsl:value-of select="concat($relative,';')"/>
  1303.             </xsl:if>
  1304.         </xsl:variable>
  1305.         <!-- image special: convert oo base64 binary data (77char/line) to word base64 binary data(73char/line) , a workthrough is removing all line breaks -->
  1306.         <xsl:if test="$ooshapename = 'image'">
  1307.             <xsl:element name="w:binData">
  1308.                 <xsl:attribute name="w:name">
  1309.                     <xsl:value-of select="concat( 'wordml://', $draw-name )"/>
  1310.                 </xsl:attribute>
  1311.                 <xsl:value-of select="translate(office:binary-data/text(),' ','' ) "/>
  1312.                 <!-- xsl:value-of select="office:binary-data/text()"/ -->
  1313.             </xsl:element>
  1314.         </xsl:if>
  1315.         <!-- all element goes here -->
  1316.         <xsl:variable name="id">
  1317.             <xsl:choose>
  1318.                 <xsl:when test="$ooshapename='line'">
  1319.                     <xsl:value-of select="concat('_x',$x1 , '_' ,$y1, '_' , $x2, '_' ,$y2 )"/>
  1320.                 </xsl:when>
  1321.                 <xsl:otherwise>
  1322.                     <xsl:value-of select="concat('_x',$x , '_' ,$y, '_' , $width, '_' ,$height )"/>
  1323.                 </xsl:otherwise>
  1324.             </xsl:choose>
  1325.         </xsl:variable>
  1326.         <xsl:element name="{$element-name}">
  1327.             <xsl:attribute name="id">
  1328.                 <xsl:value-of select="$id"/>
  1329.             </xsl:attribute>
  1330.             <xsl:if test="string-length($ms-shape-type) > 0">
  1331.                 <xsl:attribute name="type">
  1332.                     <xsl:value-of select="$ms-shape-type"/>
  1333.                 </xsl:attribute>
  1334.             </xsl:if>
  1335.             <xsl:attribute name="style">
  1336.                 <xsl:value-of select="$style"/>
  1337.             </xsl:attribute>
  1338.             <xsl:if test="$stroke-weight > 0">
  1339.                 <xsl:attribute name="strokeweight">
  1340.                     <xsl:value-of select="concat($stroke-weight,$MeasureMark)"/>
  1341.                 </xsl:attribute>
  1342.             </xsl:if>
  1343.             <xsl:if test="string-length($stroked) > 0">
  1344.                 <xsl:attribute name="stroked">
  1345.                     <xsl:value-of select="$stroked"/>
  1346.                 </xsl:attribute>
  1347.             </xsl:if>
  1348.             <xsl:if test="string-length($stroke-color) > 0">
  1349.                 <xsl:attribute name="strokecolor">
  1350.                     <xsl:value-of select="$stroke-color"/>
  1351.                 </xsl:attribute>
  1352.             </xsl:if>
  1353.             <xsl:if test="string-length($fill-color) > 0">
  1354.                 <xsl:attribute name="fillcolor">
  1355.                     <xsl:value-of select="$fill-color"/>
  1356.                 </xsl:attribute>
  1357.                 <xsl:attribute name="filled">true</xsl:attribute>
  1358.             </xsl:if>
  1359.             <xsl:if test="parent::draw:frame/draw:object-ole[1]">
  1360.                 <xsl:attribute name="filled">true</xsl:attribute>
  1361.             </xsl:if>
  1362.             <xsl:if test="string-length($stroke-opacity) > 0">
  1363.                 <xsl:attribute name="opacity">
  1364.                     <xsl:value-of select="$stroke-opacity"/>
  1365.                 </xsl:attribute>
  1366.             </xsl:if>
  1367.             <!-- arc special attribute -->
  1368.             <xsl:if test="@draw:kind = 'arc' or @draw:kind = 'cut' or @draw:kind = 'section'">
  1369.                 <xsl:choose>
  1370.                     <xsl:when test="@draw:start-angle > @draw:end-angle">
  1371.                         <xsl:attribute name="startangle">
  1372.                             <xsl:value-of select="round( 450 - (@draw:end-angle + 360)  )"/>
  1373.                         </xsl:attribute>
  1374.                     </xsl:when>
  1375.                     <xsl:otherwise>
  1376.                         <xsl:attribute name="startangle">
  1377.                             <xsl:value-of select="round( 450 - @draw:end-angle  )"/>
  1378.                         </xsl:attribute>
  1379.                     </xsl:otherwise>
  1380.                 </xsl:choose>
  1381.                 <xsl:attribute name="endangle">
  1382.                     <xsl:value-of select="round(450 - @draw:start-angle)"/>
  1383.                 </xsl:attribute>
  1384.             </xsl:if>
  1385.             <xsl:if test="@draw:kind = 'cut'">
  1386.                 <xsl:attribute name="fill">
  1387.                     <xsl:value-of select="'true'"/>
  1388.                 </xsl:attribute>
  1389.             </xsl:if>
  1390.             <!-- end arc special attribute -->
  1391.             <!-- line special attribute-->
  1392.             <xsl:if test="$ooshapename='line'">
  1393.                 <xsl:attribute name="from">
  1394.                     <xsl:choose>
  1395.                         <xsl:when test="@text:anchor-type='as-char'">0,0</xsl:when>
  1396.                         <xsl:otherwise>
  1397.                             <xsl:value-of select="concat($x1,$MeasureMark, ',',$y2,$MeasureMark )"/>
  1398.                         </xsl:otherwise>
  1399.                     </xsl:choose>
  1400.                 </xsl:attribute>
  1401.                 <xsl:attribute name="to">
  1402.                     <xsl:choose>
  1403.                         <xsl:when test="@text:anchor-type='as-char'">
  1404.                             <xsl:value-of select="concat($x2,$MeasureMark ,',',$y2,$MeasureMark )"/>
  1405.                         </xsl:when>
  1406.                         <xsl:otherwise>
  1407.                             <xsl:value-of select="concat($x2,$MeasureMark ,',' ,$y1,$MeasureMark)"/>
  1408.                         </xsl:otherwise>
  1409.                     </xsl:choose>
  1410.                 </xsl:attribute>
  1411.             </xsl:if>
  1412.             <!-- end line special attribute-->
  1413.             <!-- polyline and polygon special attribute-->
  1414.             <xsl:if test="$ooshapename='polyline' or $ooshapename='polygon' ">
  1415.                 <!-- translate ' '  to in '  tranclate ',' to 'in,' -->
  1416.                 <xsl:variable name="points">
  1417.                     <xsl:call-template name="points2points">
  1418.                         <xsl:with-param name="input_x" select="$x"/>
  1419.                         <xsl:with-param name="input_y" select="$y"/>
  1420.                         <xsl:with-param name="input_width" select="$width"/>
  1421.                         <xsl:with-param name="input_height" select="$height"/>
  1422.                         <xsl:with-param name="input_boxwidth" select="substring-before(substring-after(@svg:viewBox,'0 0 '),' ')"/>
  1423.                         <xsl:with-param name="input_boxheight" select="substring-after(substring-after(@svg:viewBox,'0 0 '),' ')"/>
  1424.                         <xsl:with-param name="input_points" select="concat(@draw:points,' ')"/>
  1425.                         <!-- add a space to the end of input_points -->
  1426.                     </xsl:call-template>
  1427.                 </xsl:variable>
  1428.                 <xsl:attribute name="points">
  1429.                     <xsl:value-of select="$points"/>
  1430.                 </xsl:attribute>
  1431.             </xsl:if>
  1432.             <!-- end polyline and polygon special attribute-->
  1433.             <!-- callouts special attribute-->
  1434.             <xsl:if test="$ooshapename='caption'">
  1435.                 <xsl:variable name="caption-point-x">
  1436.                     <xsl:call-template name="ConvertMeasure">
  1437.                         <xsl:with-param name="TargetMeasure" select="'twip'"/>
  1438.                         <xsl:with-param name="value" select="@draw:caption-point-x"/>
  1439.                     </xsl:call-template>
  1440.                 </xsl:variable>
  1441.                 <xsl:variable name="caption-point-y">
  1442.                     <xsl:call-template name="ConvertMeasure">
  1443.                         <xsl:with-param name="TargetMeasure" select="'twip'"/>
  1444.                         <xsl:with-param name="value" select="@draw:caption-point-y"/>
  1445.                     </xsl:call-template>
  1446.                 </xsl:variable>
  1447.                 <xsl:attribute name="type">
  1448.                     <!-- map to word line label 3-->
  1449.                     <xsl:value-of select="'#_x0000_t48'"/>
  1450.                 </xsl:attribute>
  1451.                 <xsl:attribute name="adj">
  1452.                     <xsl:value-of select=" concat($caption-point-x * 20 , ',' , $caption-point-y * 20 , ',' ,  $caption-point-x * 10 , ',,,,' , $caption-point-x * 20, ',' , $caption-point-y * 20) "/>
  1453.                 </xsl:attribute>
  1454.             </xsl:if>
  1455.             <!-- end callouts special attribute-->
  1456.             <!-- path special attribute-->
  1457.             <xsl:if test="$ooshapename='path' or string-length(@svg:d) > 0 or ( $ooshapename='custom-shape' and draw:enhanced-geometry[1]/@draw:predefined-type = 'non-primitive') ">
  1458.                 <xsl:variable name="path">
  1459.                     <xsl:choose>
  1460.                         <xsl:when test="$ooshapename='path' or string-length(@svg:d) > 0 ">
  1461.                             <xsl:call-template name="svgpath2vmlpath">
  1462.                                 <xsl:with-param name="svg-path" select="@svg:d"/>
  1463.                             </xsl:call-template>
  1464.                         </xsl:when>
  1465.                         <xsl:otherwise>
  1466.                             <xsl:call-template name="svgpath2vmlpath">
  1467.                                 <xsl:with-param name="svg-path" select="draw:enhanced-geometry[1]/@draw:enhanced-path"/>
  1468.                             </xsl:call-template>
  1469.                         </xsl:otherwise>
  1470.                     </xsl:choose>
  1471.                 </xsl:variable>
  1472.                 <xsl:attribute name="coordorigin">
  1473.                     <xsl:value-of select=" '0 0' "/>
  1474.                 </xsl:attribute>
  1475.                 <xsl:attribute name="coordsize">
  1476.                     <xsl:choose>
  1477.                         <xsl:when test="string-length(@svg:viewBox) > 0 ">
  1478.                             <xsl:value-of select="substring-after(@svg:viewBox,'0 0 ')"/>
  1479.                         </xsl:when>
  1480.                         <xsl:when test="string-length(draw:enhanced-geometry[1]/@svg:viewBox) > 0 ">
  1481.                             <xsl:value-of select="substring-after(draw:enhanced-geometry[1]/@svg:viewBox,'0 0 ')"/>
  1482.                         </xsl:when>
  1483.                         <!-- for custom shape use a default viewbox. right? -->
  1484.                         <xsl:otherwise>
  1485.                             <xsl:value-of select=" '21600 21600' "/>
  1486.                         </xsl:otherwise>
  1487.                     </xsl:choose>
  1488.                 </xsl:attribute>
  1489.                 <xsl:attribute name="path">
  1490.                     <xsl:value-of select="$path"/>
  1491.                 </xsl:attribute>
  1492.             </xsl:if>
  1493.             <!-- end path special attribute-->
  1494.             <!-- image special element -->
  1495.             <xsl:if test="$ooshapename='image'">
  1496.                 <xsl:element name="v:imagedata">
  1497.                     <xsl:attribute name="src">
  1498.                         <xsl:value-of select="concat('wordml://', $draw-name)"/>
  1499.                     </xsl:attribute>
  1500.                     <xsl:attribute name="o:title">
  1501.                         <xsl:value-of select="$draw-name"/>
  1502.                     </xsl:attribute>
  1503.                 </xsl:element>
  1504.             </xsl:if>
  1505.             <!-- end image special element -->
  1506.             <!-- start dash style  , line style and arrow style-->
  1507.             <xsl:if test="string-length($dashstyle) > 0 or string-length($linestyle) > 0  or string-length($start-arrow) > 0  or string-length($end-arrow) > 0 ">
  1508.                 <xsl:element name="v:stroke">
  1509.                     <xsl:if test="string-length($dashstyle) > 0">
  1510.                         <xsl:attribute name="dashstyle">
  1511.                             <xsl:value-of select="$dashstyle"/>
  1512.                         </xsl:attribute>
  1513.                     </xsl:if>
  1514.                     <xsl:if test="string-length($linestyle) > 0">
  1515.                         <xsl:attribute name="linestyle">
  1516.                             <xsl:value-of select="$linestyle"/>
  1517.                         </xsl:attribute>
  1518.                     </xsl:if>
  1519.                     <xsl:if test="string-length($start-arrow) > 0 ">
  1520.                         <xsl:attribute name="startarrow">
  1521.                             <xsl:value-of select="$start-arrow"/>
  1522.                         </xsl:attribute>
  1523.                     </xsl:if>
  1524.                     <xsl:if test="string-length($end-arrow) > 0 ">
  1525.                         <xsl:attribute name="endarrow">
  1526.                             <xsl:value-of select="$end-arrow"/>
  1527.                         </xsl:attribute>
  1528.                     </xsl:if>
  1529.                     <xsl:if test="string-length($start-arrow-length) > 0 ">
  1530.                         <xsl:attribute name="startarrowlength">
  1531.                             <xsl:value-of select="$start-arrow-length"/>
  1532.                         </xsl:attribute>
  1533.                     </xsl:if>
  1534.                     <xsl:if test="string-length($start-arrow-width) > 0 ">
  1535.                         <xsl:attribute name="startarrowwidth">
  1536.                             <xsl:value-of select="$start-arrow-width"/>
  1537.                         </xsl:attribute>
  1538.                     </xsl:if>
  1539.                     <xsl:if test="string-length($end-arrow-length) > 0 ">
  1540.                         <xsl:attribute name="endarrowlength">
  1541.                             <xsl:value-of select="$end-arrow-length"/>
  1542.                         </xsl:attribute>
  1543.                     </xsl:if>
  1544.                     <xsl:if test="string-length($end-arrow-width) > 0 ">
  1545.                         <xsl:attribute name="endarrowwidth">
  1546.                             <xsl:value-of select="$end-arrow-width"/>
  1547.                         </xsl:attribute>
  1548.                     </xsl:if>
  1549.                 </xsl:element>
  1550.             </xsl:if>
  1551.             <!-- end dash style , line style and arrow style -->
  1552.             <!-- start wrap type -->
  1553.             <xsl:if test="string-length($wrap) > 0">
  1554.                 <xsl:element name="w10:wrap">
  1555.                     <xsl:attribute name="type">
  1556.                         <xsl:value-of select="$wrap"/>
  1557.                     </xsl:attribute>
  1558.                 </xsl:element>
  1559.             </xsl:if>
  1560.             <!-- end wrap type -->
  1561.             <!-- start anchor to char specific element -->
  1562.             <xsl:if test="string-length($anchorlock) > 0">
  1563.                 <xsl:element name="w10:anchorlock"/>
  1564.             </xsl:if>
  1565.             <!-- end wrap type -->
  1566.             <!-- start fill image -->
  1567.             <xsl:if test="string-length($draw-fill-type ) > 0">
  1568.                 <xsl:element name="v:fill">
  1569.                     <xsl:choose>
  1570.                         <xsl:when test="$draw-fill-type = 'bitmap'">
  1571.                             <xsl:attribute name="src">
  1572.                                 <xsl:value-of select="concat( 'wordml://', $fill-image-name)"/>
  1573.                             </xsl:attribute>
  1574.                             <xsl:attribute name="o:titile">
  1575.                                 <xsl:value-of select="$fill-image-name"/>
  1576.                             </xsl:attribute>
  1577.                             <xsl:attribute name="recolor">
  1578.                                 <xsl:value-of select=" 'true' "/>
  1579.                             </xsl:attribute>
  1580.                             <xsl:attribute name="rotate">
  1581.                                 <xsl:value-of select=" 'true' "/>
  1582.                             </xsl:attribute>
  1583.                             <xsl:attribute name="type">
  1584.                                 <xsl:value-of select=" 'frame' "/>
  1585.                             </xsl:attribute>
  1586.                         </xsl:when>
  1587.                         <xsl:when test="$draw-fill-type = 'gradient'">
  1588.                             <xsl:attribute name="type">
  1589.                                 <xsl:value-of select=" 'gradient' "/>
  1590.                             </xsl:attribute>
  1591.                             <xsl:attribute name="color2">
  1592.                                 <xsl:value-of select="key('draw-gradient',$draw-gradient-name)/@draw:start-color "/>
  1593.                             </xsl:attribute>
  1594.                         </xsl:when>
  1595.                     </xsl:choose>
  1596.                 </xsl:element>
  1597.             </xsl:if>
  1598.             <!-- end fill image -->
  1599.             <xsl:if test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-style">
  1600.                 <xsl:call-template name="FontWork"/>
  1601.             </xsl:if>
  1602.             <xsl:if test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:shadow = 'visible'">
  1603.                 <xsl:call-template name="Shadow"/>
  1604.             </xsl:if>
  1605.             <!-- only draw:g can have child graphic -->
  1606.             <xsl:choose>
  1607.                 <xsl:when test="name() = 'draw:g'">
  1608.                     <xsl:apply-templates select="draw:*">
  1609.                         <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1610.                         <xsl:with-param name="x-adjust" select="$x-adjust"/>
  1611.                         <xsl:with-param name="y-adjust" select="$y-adjust"/>
  1612.                         <xsl:with-param name="force-draw" select="$force-draw"/>
  1613.                     </xsl:apply-templates>
  1614.                 </xsl:when>
  1615.                 <xsl:when test="text:*/* | text:*/text()">
  1616.                     <xsl:element name="v:textbox">
  1617.                         <xsl:if test="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:writing-mode = 'tb-rl'">
  1618.                             <xsl:attribute name="style">
  1619.                                 <xsl:value-of select="'layout-flow:vertical'"/>
  1620.                             </xsl:attribute>
  1621.                         </xsl:if>
  1622.                         <w:txbxContent>
  1623.                             <xsl:apply-templates select="text() | text:*"/>
  1624.                         </w:txbxContent>
  1625.                     </xsl:element>
  1626.                 </xsl:when>
  1627.             </xsl:choose>
  1628.         </xsl:element>
  1629.         <xsl:apply-templates select="parent::draw:frame/draw:object-ole" mode="output">
  1630.             <xsl:with-param name="ShapeID" select="$id"/>
  1631.         </xsl:apply-templates>
  1632.     </xsl:template>
  1633.     <xsl:template name="Shadow">
  1634.         <xsl:element name="v:shadow">
  1635.             <xsl:variable name="key-node" select="key('graphics-style', @draw:style-name)/style:graphic-properties"/>
  1636.             <xsl:attribute name="on">true</xsl:attribute>
  1637.             <xsl:attribute name="offset">
  1638.                 <xsl:value-of select="concat($key-node/@draw:shadow-offset-x,',' , $key-node/@draw:shadow-offset-y)"/>
  1639.             </xsl:attribute>
  1640.             <xsl:attribute name="color">
  1641.                 <xsl:value-of select="$key-node/@draw:shadow-color"/>
  1642.             </xsl:attribute>
  1643.             <xsl:attribute name="opacity">
  1644.                 <xsl:value-of select="$key-node/@draw:shadow-opacity"/>
  1645.             </xsl:attribute>
  1646.         </xsl:element>
  1647.     </xsl:template>
  1648.     <xsl:template name="FontWork">
  1649.         <xsl:element name="v:path">
  1650.             <xsl:attribute name="textpathok">true</xsl:attribute>
  1651.         </xsl:element>
  1652.         <xsl:if test="not(key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-shadow) or not(key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-shadow = 'normal')">
  1653.             <xsl:element name="v:shadow">
  1654.                 <xsl:attribute name="on">true</xsl:attribute>
  1655.                 <xsl:attribute name="type">perspective</xsl:attribute>
  1656.                 <xsl:attribute name="color">
  1657.                     <xsl:value-of select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-shadow-color"/>
  1658.                 </xsl:attribute>
  1659.                 <xsl:variable name="offset-x">
  1660.                     <xsl:call-template name="ConvertMeasure">
  1661.                         <xsl:with-param name="TargetMeasure" select="'twip'"/>
  1662.                         <xsl:with-param name="value" select="key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-shadow-offset-x"/>
  1663.                     </xsl:call-template>
  1664.                 </xsl:variable>
  1665.                 <xsl:variable name="offset-y" select="substring-before(key('graphics-style', @draw:style-name)/style:graphic-properties/@draw:fontwork-shadow-offset-y, 'in')"/>
  1666.                 <xsl:attribute name="matrix">
  1667.                     <xsl:value-of select="concat(',,,' , round($offset-y div 0.000693) div 100, ',,')"/>
  1668.                 </xsl:attribute>
  1669.                 <xsl:attribute name="origin">-30%, -30%</xsl:attribute>
  1670.             </xsl:element>
  1671.         </xsl:if>
  1672.         <xsl:element name="v:textpath">
  1673.             <xsl:attribute name="on">true</xsl:attribute>
  1674.             <xsl:attribute name="fitpath">true</xsl:attribute>
  1675.             <xsl:attribute name="fitshape">true</xsl:attribute>
  1676.             <xsl:attribute name="style">
  1677.                 <xsl:choose>
  1678.                     <xsl:when test="key('paragraph-style', text:p[1]/@text:style-name )/style:graphic-properties/@svg:font-family">
  1679.                         <xsl:value-of select="concat('font-family:"' , key('paragraph-style', text:p[1]/@text:style-name )/style:graphic-properties/@svg:font-family ,  '"') "/>
  1680.                     </xsl:when>
  1681.                     <xsl:otherwise>
  1682.                         <xsl:variable name="default-graphics-properties" select="/office:document/office:styles/style:default-style[@style:family = 'graphics']/style:graphic-properties"/>
  1683.                         <xsl:value-of select="concat('font-family:"' , $default-graphics-properties/@style:font-name ,  '"') "/>
  1684.                     </xsl:otherwise>
  1685.                 </xsl:choose>
  1686.             </xsl:attribute>
  1687.             <xsl:attribute name="string">
  1688.                 <xsl:value-of select="text:p"/>
  1689.             </xsl:attribute>
  1690.         </xsl:element>
  1691.     </xsl:template>
  1692.     <xsl:template name="MapArrowStyle">
  1693.         <xsl:param name="arrow-name"/>
  1694.         <xsl:choose>
  1695.             <xsl:when test="$arrow-name = 'Arrow' ">Block</xsl:when>
  1696.             <xsl:when test="$arrow-name = 'Square' ">Diamond</xsl:when>
  1697.             <xsl:when test="$arrow-name = 'Small arrow' ">Block</xsl:when>
  1698.             <xsl:when test="$arrow-name = 'Dimension lines' ">Diamond</xsl:when>
  1699.             <xsl:when test="$arrow-name = 'Double Arrow' ">Block</xsl:when>
  1700.             <xsl:when test="$arrow-name = 'Rounded short arrow' ">Block</xsl:when>
  1701.             <xsl:when test="$arrow-name = 'Symmetric arrow' ">Block</xsl:when>
  1702.             <xsl:when test="$arrow-name = 'Line Arrow' ">Open</xsl:when>
  1703.             <xsl:when test="$arrow-name = 'Rounded large arrow' ">Block</xsl:when>
  1704.             <xsl:when test="$arrow-name = 'Circle' ">Oval</xsl:when>
  1705.             <xsl:when test="$arrow-name = 'Square 45' ">Diamond</xsl:when>
  1706.             <xsl:when test="$arrow-name = 'Arrow concave' ">Classic</xsl:when>
  1707.             <xsl:otherwise>Block</xsl:otherwise>
  1708.         </xsl:choose>
  1709.     </xsl:template>
  1710.     <xsl:template name="GetArrowLength">
  1711.         <xsl:param name="arrow-name"/>
  1712.         <xsl:param name="arrow-width"/>
  1713.         <xsl:variable name="arrow-size">
  1714.             <xsl:choose>
  1715.                 <xsl:when test="$arrow-width">
  1716.                     <xsl:value-of select="round(substring-before($arrow-width, 'in') div 0.02) "/>
  1717.                 </xsl:when>
  1718.                 <xsl:otherwise>3</xsl:otherwise>
  1719.             </xsl:choose>
  1720.         </xsl:variable>
  1721.         <xsl:choose>
  1722.             <xsl:when test="$arrow-size > 2">Long</xsl:when>
  1723.             <xsl:when test="$arrow-size > 1">Medium</xsl:when>
  1724.             <xsl:when test="$arrow-size > 0">Short</xsl:when>
  1725.         </xsl:choose>
  1726.     </xsl:template>
  1727.     <xsl:template name="GetArrowWidth">
  1728.         <xsl:param name="arrow-name"/>
  1729.         <xsl:param name="arrow-width"/>
  1730.         <xsl:variable name="arrow-size">
  1731.             <xsl:choose>
  1732.                 <xsl:when test="$arrow-width">
  1733.                     <xsl:value-of select="round(substring-before($arrow-width, 'in') div 0.02) "/>
  1734.                 </xsl:when>
  1735.                 <xsl:otherwise>3</xsl:otherwise>
  1736.             </xsl:choose>
  1737.         </xsl:variable>
  1738.         <xsl:choose>
  1739.             <xsl:when test="$arrow-size > 2">Wide</xsl:when>
  1740.             <xsl:when test="$arrow-size > 1">Medium</xsl:when>
  1741.             <xsl:when test="$arrow-size > 0">Narrow</xsl:when>
  1742.         </xsl:choose>
  1743.     </xsl:template>
  1744.     <xsl:template name="ConvertMeasure">
  1745.         <xsl:param name="TargetMeasure" select="'cm'"/>
  1746.         <xsl:param name="TargetTruncate" select=" 'all' "/>
  1747.         <xsl:param name="value"/>
  1748.         <!-- When TargetTruncate ='all'  it returns the number whichsoever the return value is negative or positive
  1749.                When TargetTruncate ='nonNegative' it only returns nonNegative number, all negative number to be returned as 0
  1750.                When TargetTruncate ='positive" it only returns positive number, all nonPositive number to be returned as 1 -->
  1751.         <xsl:variable name="return_value">
  1752.             <xsl:choose>
  1753.                 <!-- remove the measure mark, if the value is null, the result should be 0. Must be the first case  -->
  1754.                 <xsl:when test="string-length(translate($value,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ','')) = 0">0</xsl:when>
  1755.                 <xsl:when test="string-length(translate($value,'- .0123456789','')) = 0">
  1756.                     <xsl:value-of select="$value"/>
  1757.                 </xsl:when>
  1758.                 <xsl:when test="$TargetMeasure = 'cm'">
  1759.                     <xsl:call-template name="convert2cm">
  1760.                         <xsl:with-param name="value" select="$value"/>
  1761.                     </xsl:call-template>
  1762.                 </xsl:when>
  1763.                 <xsl:when test="$TargetMeasure = 'pt'">
  1764.                     <xsl:call-template name="convert2pt">
  1765.                         <xsl:with-param name="value" select="$value"/>
  1766.                     </xsl:call-template>
  1767.                 </xsl:when>
  1768.                 <xsl:when test="$TargetMeasure = 'twip'">
  1769.                     <xsl:call-template name="convert2twip">
  1770.                         <xsl:with-param name="value" select="$value"/>
  1771.                     </xsl:call-template>
  1772.                 </xsl:when>
  1773.                 <xsl:when test="$TargetMeasure = 'in'">
  1774.                     <xsl:call-template name="convert2in">
  1775.                         <xsl:with-param name="value" select="$value"/>
  1776.                     </xsl:call-template>
  1777.                 </xsl:when>
  1778.             </xsl:choose>
  1779.         </xsl:variable>
  1780.         <xsl:choose>
  1781.             <xsl:when test="$TargetTruncate = 'all' ">
  1782.                 <xsl:choose>
  1783.                     <xsl:when test="number($TargetMeasure) = 'NaN' ">
  1784.                         <xsl:value-of select=" '0' "/>
  1785.                     </xsl:when>
  1786.                     <xsl:otherwise>
  1787.                         <xsl:value-of select="$return_value"/>
  1788.                     </xsl:otherwise>
  1789.                 </xsl:choose>
  1790.             </xsl:when>
  1791.             <xsl:when test="$TargetTruncate = 'nonNegative' ">
  1792.                 <xsl:choose>
  1793.                     <xsl:when test="number($TargetMeasure) = 'NaN' ">
  1794.                         <xsl:value-of select=" '0' "/>
  1795.                     </xsl:when>
  1796.                     <xsl:otherwise>
  1797.                         <xsl:choose>
  1798.                             <xsl:when test=" $return_value < 0  ">
  1799.                                 <xsl:value-of select=" '0' "/>
  1800.                             </xsl:when>
  1801.                             <xsl:otherwise>
  1802.                                 <xsl:value-of select="$return_value"/>
  1803.                             </xsl:otherwise>
  1804.                         </xsl:choose>
  1805.                     </xsl:otherwise>
  1806.                 </xsl:choose>
  1807.             </xsl:when>
  1808.             <xsl:when test="$TargetTruncate = 'positive' ">
  1809.                 <xsl:choose>
  1810.                     <xsl:when test="number($TargetMeasure) = 'NaN' ">
  1811.                         <xsl:value-of select=" '1' "/>
  1812.                     </xsl:when>
  1813.                     <xsl:otherwise>
  1814.                         <xsl:choose>
  1815.                             <xsl:when test=" $return_value <= 0 ">
  1816.                                 <xsl:value-of select=" '1' "/>
  1817.                             </xsl:when>
  1818.                             <xsl:otherwise>
  1819.                                 <xsl:value-of select="$return_value"/>
  1820.                             </xsl:otherwise>
  1821.                         </xsl:choose>
  1822.                     </xsl:otherwise>
  1823.                 </xsl:choose>
  1824.             </xsl:when>
  1825.         </xsl:choose>
  1826.     </xsl:template>
  1827.     <xsl:template name="Add-With-Measure">
  1828.         <xsl:param name="value1"/>
  1829.         <xsl:param name="value2"/>
  1830.         <xsl:param name="TargetMeasure" select="'in'"/>
  1831.         <xsl:variable name="number-value1">
  1832.             <xsl:call-template name="ConvertMeasure">
  1833.                 <xsl:with-param name="value" select="$value1"/>
  1834.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1835.             </xsl:call-template>
  1836.         </xsl:variable>
  1837.         <xsl:variable name="number-value2">
  1838.             <xsl:call-template name="ConvertMeasure">
  1839.                 <xsl:with-param name="value" select="$value2"/>
  1840.                 <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  1841.             </xsl:call-template>
  1842.         </xsl:variable>
  1843.         <xsl:value-of select="$number-value1 + $number-value2"/>
  1844.     </xsl:template>
  1845.     <xsl:template name="export-oledata">
  1846.         <xsl:if test="//draw:object-ole[1]">
  1847.             <oleextracter:init UNOURL="uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"/>
  1848.             <xsl:apply-templates select="//draw:object-ole" mode="oledata.mso"/>
  1849.             <w:docOleData>
  1850.                 <w:binData w:name="oledata.mso">
  1851.                     <xsl:value-of select="translate(oleextracter:getByName('oledata.mso'),' ','')"/>
  1852.                 </w:binData>
  1853.             </w:docOleData>
  1854.             <oleextracter:exit/>
  1855.         </xsl:if>
  1856.     </xsl:template>
  1857.     <xsl:template match="draw:object-ole" mode="oledata.mso">
  1858.         <xsl:variable name="stream-name">
  1859.             <xsl:apply-templates select="." mode="get-number"/>
  1860.         </xsl:variable>
  1861.         <xsl:variable name="tmp" select="oleextracter:insertByName($stream-name, translate(office:binary-data/text(),' ','' )  )"/>
  1862.     </xsl:template>
  1863.     <xsl:template match="draw:object-ole" mode="output">
  1864.         <xsl:param name="ShapeID"/>
  1865.         <xsl:variable name="stream-name">
  1866.             <xsl:apply-templates select="." mode="get-number"/>
  1867.         </xsl:variable>
  1868.         <o:OLEObject Type="Embed" DrawAspect="Content" ObjectID="{$stream-name}" ShapeID="{$ShapeID}" ProgID=""/>
  1869.     </xsl:template>
  1870.     <xsl:template match="draw:object-ole" mode="get-number">
  1871.         <xsl:number from="/office:document" level="any" count="draw:object-ole" format="1"/>
  1872.     </xsl:template>
  1873.     <xsl:template match="draw:object-ole"/>
  1874.     <xalan:component prefix="oleextracter" elements="init exit" functions="getByName insertByName">
  1875.         <xalan:script lang="javaclass" src="xalan://XSLTXalanOLEExtracter"/>
  1876.     </xalan:component>
  1877. </xsl:stylesheet>
  1878.